[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/ -> bootstrap.php (source)

   1  <?php
   2  
   3  /**
   4   * Bootstrap file for the Joomla! CMS [with legacy libraries].
   5   * Including this file into your application will make Joomla libraries available for use.
   6   *
   7   * @copyright  (C) 2016 Open Source Matters, Inc. <https://www.joomla.org>
   8   * @license    GNU General Public License version 2 or later; see LICENSE
   9   */
  10  
  11  defined('_JEXEC') or die;
  12  
  13  // Set the platform root path as a constant if necessary.
  14  defined('JPATH_PLATFORM') or define('JPATH_PLATFORM', __DIR__);
  15  
  16  // Detect the native operating system type.
  17  $os = strtoupper(substr(PHP_OS, 0, 3));
  18  
  19  defined('IS_WIN') or define('IS_WIN', ($os === 'WIN'));
  20  defined('IS_UNIX') or define('IS_UNIX', (($os !== 'MAC') && ($os !== 'WIN')));
  21  
  22  // Import the library loader if necessary.
  23  if (!class_exists('JLoader')) {
  24      require_once  JPATH_PLATFORM . '/loader.php';
  25  
  26      // If JLoader still does not exist panic.
  27      if (!class_exists('JLoader')) {
  28          throw new RuntimeException('Joomla Platform not loaded.');
  29      }
  30  }
  31  
  32  // Setup the autoloaders.
  33  JLoader::setup();
  34  
  35  // Create the Composer autoloader
  36  /** @var \Composer\Autoload\ClassLoader $loader */
  37  $loader = require  JPATH_LIBRARIES . '/vendor/autoload.php';
  38  
  39  // We need to pull our decorated class loader into memory before unregistering Composer's loader
  40  class_exists('\\Joomla\\CMS\\Autoload\\ClassLoader');
  41  
  42  $loader->unregister();
  43  
  44  // Decorate Composer autoloader
  45  spl_autoload_register([new \Joomla\CMS\Autoload\ClassLoader($loader), 'loadClass'], true, true);
  46  
  47  // Register the class aliases for Framework classes that have replaced their Platform equivalents
  48  require_once  JPATH_LIBRARIES . '/classmap.php';
  49  
  50  /**
  51   * Register the global exception handler. And set error level to server default error level.
  52   * The error level may be changed later in boot up process, after application config will be loaded.
  53   * Do not remove the variable, to allow to use it further, after including this file.
  54   */
  55  $errorHandler = \Symfony\Component\ErrorHandler\ErrorHandler::register();
  56  \Symfony\Component\ErrorHandler\ErrorRenderer\HtmlErrorRenderer::setTemplate(__DIR__ . '/../templates/system/fatal.php');
  57  
  58  // Register the error handler which processes E_USER_DEPRECATED errors
  59  if (error_reporting() & E_USER_DEPRECATED) {
  60      set_error_handler(['Joomla\CMS\Exception\ExceptionHandler', 'handleUserDeprecatedErrors'], E_USER_DEPRECATED);
  61  }
  62  
  63  // Suppress phar stream wrapper for non .phar files
  64  $behavior = new \TYPO3\PharStreamWrapper\Behavior();
  65  \TYPO3\PharStreamWrapper\Manager::initialize(
  66      $behavior->withAssertion(new \TYPO3\PharStreamWrapper\Interceptor\PharExtensionInterceptor())
  67  );
  68  
  69  if (in_array('phar', stream_get_wrappers())) {
  70      stream_wrapper_unregister('phar');
  71      stream_wrapper_register('phar', 'TYPO3\\PharStreamWrapper\\PharStreamWrapper');
  72  }
  73  
  74  // Define the Joomla version if not already defined.
  75  defined('JVERSION') or define('JVERSION', (new \Joomla\CMS\Version())->getShortVersion());
  76  
  77  // Set up the message queue logger for web requests
  78  if (array_key_exists('REQUEST_METHOD', $_SERVER)) {
  79      \Joomla\CMS\Log\Log::addLogger(['logger' => 'messagequeue'], \Joomla\CMS\Log\Log::ALL, ['jerror']);
  80  }
  81  
  82  // Register the Crypto lib
  83  JLoader::register('Crypto', JPATH_PLATFORM . '/php-encryption/Crypto.php');
  84  
  85  // Register the PasswordHash library.
  86  JLoader::register('PasswordHash', JPATH_PLATFORM . '/phpass/PasswordHash.php');


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer