Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
bootstrap.php
Go to the documentation of this file.
1 <?php
10 error_reporting(E_ALL);
11 #ini_set('display_errors', 1);
12 
13 /* PHP version validation */
14 if (!defined('PHP_VERSION_ID') || !(PHP_VERSION_ID === 70002 || PHP_VERSION_ID === 70004 || PHP_VERSION_ID >= 70006)) {
15  if (PHP_SAPI == 'cli') {
16  echo 'Magento supports 7.0.2, 7.0.4, and 7.0.6 or later. ' .
17  'Please read http://devdocs.magento.com/guides/v2.2/install-gde/system-requirements.html';
18  } else {
19  echo <<<HTML
20 <div style="font:12px/1.35em arial, helvetica, sans-serif;">
21  <p>Magento supports PHP 7.0.2, 7.0.4, and 7.0.6 or later. Please read
22  <a target="_blank" href="http://devdocs.magento.com/guides/v2.2/install-gde/system-requirements.html">
23  Magento System Requirements</a>.
24 </div>
25 HTML;
26  }
27  exit(1);
28 }
29 
30 require_once __DIR__ . '/autoload.php';
31 // Sets default autoload mappings, may be overridden in Bootstrap::create
33 
34 /* Custom umask value may be provided in optional mage_umask file in root */
35 $umaskFile = BP . '/magento_umask';
36 $mask = file_exists($umaskFile) ? octdec(file_get_contents($umaskFile)) : 002;
37 umask($mask);
38 
39 if (empty($_SERVER['ENABLE_IIS_REWRITES']) || ($_SERVER['ENABLE_IIS_REWRITES'] != 1)) {
40  /*
41  * Unset headers used by IIS URL rewrites.
42  */
43  unset($_SERVER['HTTP_X_REWRITE_URL']);
44  unset($_SERVER['HTTP_X_ORIGINAL_URL']);
45  unset($_SERVER['IIS_WasUrlRewritten']);
46  unset($_SERVER['UNENCODED_URL']);
47  unset($_SERVER['ORIG_PATH_INFO']);
48 }
49 
50 if (
51  (!empty($_SERVER['MAGE_PROFILER']) || file_exists(BP . '/var/profiler.flag'))
52  && isset($_SERVER['HTTP_ACCEPT'])
53  && strpos($_SERVER['HTTP_ACCEPT'], 'text/html') !== false
54 ) {
55  $profilerConfig = isset($_SERVER['MAGE_PROFILER']) && strlen($_SERVER['MAGE_PROFILER'])
56  ? $_SERVER['MAGE_PROFILER']
57  : trim(file_get_contents(BP . '/var/profiler.flag'));
58 
59  if ($profilerConfig) {
60  $profilerConfig = json_decode($profilerConfig, true) ?: $profilerConfig;
61  }
62 
64  $profilerConfig,
65  BP,
66  !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'
67  );
68 }
69 
70 date_default_timezone_set('UTC');
71 
72 /* For data consistency between displaying (printing) and serialization a float number */
73 ini_set('precision', 14);
74 ini_set('serialize_precision', 14);
ini_set($varName, $newValue)
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60
$mask
Definition: bootstrap.php:36
exit
Definition: redirect.phtml:12
$umaskFile
Definition: bootstrap.php:35
const BP
Definition: autoload.php:14
static applyConfig($config, $baseDir, $isAjax=false)
Definition: Profiler.php:332
static populateAutoloader($rootDir, $initParams)
Definition: Bootstrap.php:135