forked from symfony/requirements-checker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Environment value to be checked + xdebug recommendation on produc…
…tion
- Loading branch information
Showing
1 changed file
with
45 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,10 +17,11 @@ | |
* | ||
* @author Tobias Schultze <http://tobion.de> | ||
* @author Fabien Potencier <[email protected]> | ||
* @author Fabien Potencier <[email protected]> | ||
*/ | ||
class SymfonyRequirements extends RequirementCollection | ||
{ | ||
const REQUIRED_PHP_VERSION = '5.5.9'; | ||
const REQUIRED_PHP_VERSION = '7.2.8'; | ||
|
||
public function __construct($rootDir) | ||
{ | ||
|
@@ -30,6 +31,8 @@ public function __construct($rootDir) | |
|
||
$rootDir = $this->getComposerRootDir($rootDir); | ||
$options = $this->readComposer($rootDir); | ||
$appEnv = getenv('APP_ENV') ?? 'dev'; | ||
|
||
|
||
$this->addRequirement( | ||
version_compare($installedPhpVersion, self::REQUIRED_PHP_VERSION, '>='), | ||
|
@@ -44,7 +47,7 @@ public function __construct($rootDir) | |
is_dir($rootDir.'/vendor/composer'), | ||
'Vendor libraries must be installed', | ||
'Vendor libraries are missing. Install composer following instructions from <a href="http://getcomposer.org/">http://getcomposer.org/</a>. '. | ||
'Then run "<strong>php composer.phar install</strong>" to install them.' | ||
'Then run "<strong>php composer.phar install</strong>" to install them.' | ||
); | ||
|
||
if (is_dir($cacheDir = $rootDir.'/'.$options['var-dir'].'/cache')) { | ||
|
@@ -143,24 +146,36 @@ function($cfgValue) { return false !== stripos($cfgValue, 'phar'); }, | |
); | ||
} | ||
|
||
if (extension_loaded('xdebug')) { | ||
$this->addPhpConfigRequirement( | ||
'xdebug.show_exception_trace', false, true | ||
); | ||
if ($appEnv !== 'prod' ) { | ||
if (extension_loaded('xdebug')) { | ||
$this->addPhpConfigRequirement( | ||
'xdebug.show_exception_trace', false, true | ||
); | ||
|
||
$this->addPhpConfigRequirement( | ||
'xdebug.scream', false, true | ||
); | ||
$this->addPhpConfigRequirement( | ||
'xdebug.scream', false, true | ||
); | ||
|
||
$this->addPhpConfigRecommendation( | ||
'xdebug.max_nesting_level', | ||
function ($cfgValue) { return $cfgValue > 100; }, | ||
true, | ||
'xdebug.max_nesting_level should be above 100 in php.ini', | ||
'Set "<strong>xdebug.max_nesting_level</strong>" to e.g. "<strong>250</strong>" in php.ini<a href="#phpini">*</a> to stop Xdebug\'s infinite recursion protection erroneously throwing a fatal error in your project.' | ||
); | ||
} | ||
} else { | ||
$this->addPhpConfigRecommendation( | ||
'xdebug.max_nesting_level', | ||
function ($cfgValue) { return $cfgValue > 100; }, | ||
true, | ||
'xdebug.max_nesting_level should be above 100 in php.ini', | ||
'Set "<strong>xdebug.max_nesting_level</strong>" to e.g. "<strong>250</strong>" in php.ini<a href="#phpini">*</a> to stop Xdebug\'s infinite recursion protection erroneously throwing a fatal error in your project.' | ||
'xdebug.enabled', | ||
extension_loaded('xdebug'), | ||
false, | ||
'xdebug should be disabled', | ||
'To increase platform performances, <strong>xdebug</strong> should be disabled in production mode.', | ||
'To increase platform performances, xdebug should be disabled in production mode.' | ||
); | ||
} | ||
|
||
|
||
$pcreVersion = defined('PCRE_VERSION') ? (float) PCRE_VERSION : null; | ||
|
||
$this->addRequirement( | ||
|
@@ -315,13 +330,17 @@ function ($cfgValue) { return (int) $cfgValue === 0; }, | |
|
||
$this->addPhpConfigRecommendation('session.auto_start', false); | ||
|
||
$this->addPhpConfigRecommendation( | ||
'xdebug.max_nesting_level', | ||
function ($cfgValue) { return $cfgValue > 100; }, | ||
true, | ||
'xdebug.max_nesting_level should be above 100 in php.ini', | ||
'Set "<strong>xdebug.max_nesting_level</strong>" to e.g. "<strong>250</strong>" in php.ini<a href="#phpini">*</a> to stop Xdebug\'s infinite recursion protection erroneously throwing a fatal error in your project.' | ||
); | ||
if ($appEnv !== 'prod' ) { | ||
$this->addPhpConfigRecommendation( | ||
'xdebug.max_nesting_level', | ||
function ( $cfgValue ) { | ||
return $cfgValue > 100; | ||
}, | ||
true, | ||
'xdebug.max_nesting_level should be above 100 in php.ini', | ||
'Set "<strong>xdebug.max_nesting_level</strong>" to e.g. "<strong>250</strong>" in php.ini<a href="#phpini">*</a> to stop Xdebug\'s infinite recursion protection erroneously throwing a fatal error in your project.' | ||
); | ||
} | ||
|
||
$this->addPhpConfigRecommendation( | ||
'post_max_size', | ||
|
@@ -412,7 +431,7 @@ private function getRealpathCacheSize() | |
* | ||
* @return int | ||
*/ | ||
private function getPostMaxSize() | ||
public function getPostMaxSize() | ||
{ | ||
return $this->convertShorthandSize(ini_get('post_max_size')); | ||
} | ||
|
@@ -422,7 +441,7 @@ private function getPostMaxSize() | |
* | ||
* @return int | ||
*/ | ||
private function getMemoryLimit() | ||
public function getMemoryLimit() | ||
{ | ||
return $this->convertShorthandSize(ini_get('memory_limit')); | ||
} | ||
|
@@ -432,12 +451,12 @@ private function getMemoryLimit() | |
* | ||
* @return int | ||
*/ | ||
private function getUploadMaxFilesize() | ||
public function getUploadMaxFilesize() | ||
{ | ||
return $this->convertShorthandSize(ini_get('upload_max_filesize')); | ||
} | ||
|
||
private function getComposerRootDir($rootDir) | ||
public function getComposerRootDir($rootDir) | ||
{ | ||
$dir = $rootDir; | ||
while (!file_exists($dir.'/composer.json')) { | ||
|
@@ -474,4 +493,4 @@ private function readComposer($rootDir) | |
|
||
return $options; | ||
} | ||
} | ||
} |