8 use Composer\Package\Version\VersionParser;
21 private $composerInformation;
26 private $phpInformation;
31 private $versionParser;
51 VersionParser $versionParser,
54 $this->composerInformation = $composerInformation;
55 $this->phpInformation = $phpInformation;
56 $this->versionParser = $versionParser;
68 $requiredVersion = $this->composerInformation->getRequiredPhpVersion();
73 'error' =>
'phpVersionError',
74 'message' =>
'Cannot determine required PHP version: ' . $e->getMessage()
78 $multipleConstraints = $this->versionParser->parseConstraints($requiredVersion);
79 $normalizedPhpVersion = $this->getNormalizedCurrentPhpVersion(PHP_VERSION);
80 $currentPhpVersion = $this->versionParser->parseConstraints($normalizedPhpVersion);
82 if (!$multipleConstraints->matches($currentPhpVersion)) {
86 'responseType' => $responseType,
88 'required' => $requiredVersion,
89 'current' => PHP_VERSION,
104 $this->checkXDebugNestedLevel(),
105 $this->checkPopulateRawPostSetting(),
106 $this->checkFunctionsExistence()
110 if ($setting[
'error']) {
116 'responseType' => $responseType,
131 $this->checkXDebugNestedLevel(),
136 if ($setting[
'error']) {
142 'responseType' => $responseType,
155 $required = $this->composerInformation->getRequiredExtensions();
156 $current = $this->phpInformation->getCurrent();
161 'error' =>
'phpExtensionError',
162 'message' =>
'Cannot determine required PHP extensions: ' . $e->getMessage()
167 $missing = array_values(array_diff(
$required, $current));
172 'responseType' => $responseType,
175 'missing' => $missing,
190 $minimumRequiredMemoryLimit =
'756M';
191 $recommendedForUpgradeMemoryLimit =
'2G';
193 $currentMemoryLimit =
ini_get(
'memory_limit');
195 $currentMemoryInteger = intval($currentMemoryLimit);
197 if ($currentMemoryInteger > 0
198 && $this->dataSize->convertSizeToBytes($currentMemoryLimit)
199 < $this->dataSize->convertSizeToBytes($minimumRequiredMemoryLimit)
203 'Your current PHP memory limit is %s. 204 Magento 2 requires it to be set to %s or more. 205 As a user with root privileges, edit your php.ini file to increase memory_limit. 206 (The command php --ini tells you where it is located.) 207 After that, restart your web server and try again.',
209 $minimumRequiredMemoryLimit
211 }
elseif ($currentMemoryInteger > 0
212 && $this->dataSize->convertSizeToBytes($currentMemoryLimit)
213 < $this->dataSize->convertSizeToBytes($recommendedForUpgradeMemoryLimit)
217 'Your current PHP memory limit is %s. 218 We recommend it to be set to %s or more to use Setup Wizard. 219 As a user with root privileges, edit your php.ini file to increase memory_limit. 220 (The command php --ini tells you where it is located.) 221 After that, restart your web server and try again.',
223 $recommendedForUpgradeMemoryLimit
227 $data[
'memory_limit'] = [
230 'warning' => $warning,
240 private function checkXDebugNestedLevel()
245 $currentExtensions = $this->phpInformation->getCurrent();
246 if (in_array(
'xdebug', $currentExtensions)) {
247 $currentXDebugNestingLevel = intval(
ini_get(
'xdebug.max_nesting_level'));
248 $minimumRequiredXDebugNestedLevel = $this->phpInformation->getRequiredMinimumXDebugNestedLevel();
250 if ($minimumRequiredXDebugNestedLevel > $currentXDebugNestingLevel) {
255 'Your current setting of xdebug.max_nesting_level=%d. 256 Magento 2 requires it to be set to %d or more. 257 Edit your config, restart web server, and try again.',
258 $currentXDebugNestingLevel,
259 $minimumRequiredXDebugNestedLevel
262 $data[
'xdebug_max_nesting_level'] = [
280 private function checkPopulateRawPostSetting()
283 if (version_compare(PHP_VERSION,
'7.0.0-beta') >= 0 || defined(
'HHVM_VERSION')) {
289 $iniSetting = intval(
ini_get(
'always_populate_raw_post_data'));
291 $checkVersionConstraint = $this->versionParser->parseConstraints(
'~5.6.0');
292 $normalizedPhpVersion = $this->getNormalizedCurrentPhpVersion(PHP_VERSION);
293 $currentVersion = $this->versionParser->parseConstraints($normalizedPhpVersion);
294 if ($checkVersionConstraint->matches($currentVersion) && $iniSetting !== -1) {
299 'Your PHP Version is %s, but always_populate_raw_post_data = %d. 300 $HTTP_RAW_POST_DATA is deprecated from PHP 5.6 onwards and will be removed in PHP 7.0. 301 This will stop the installer from running. 302 Please open your php.ini file and set always_populate_raw_post_data to -1. 303 If you need more help please call your hosting provider.',
305 intval(
ini_get(
'always_populate_raw_post_data'))
308 $data[
'always_populate_raw_post_data'] = [
310 'helpUrl' =>
'http://php.net/manual/en/ini.core.php#ini.always-populate-settings-data',
322 private function checkFunctionsExistence()
325 $requiredFunctions = [
327 'name' =>
'imagecreatefromjpeg',
328 'message' =>
'You must have installed GD library with --with-jpeg-dir=DIR option.',
329 'helpUrl' =>
'http://php.net/manual/en/image.installation.php',
333 foreach ($requiredFunctions as $function) {
334 $data[
'missed_function_' . $function[
'name']] = [
335 'message' => $function[
'message'],
336 'helpUrl' => $function[
'helpUrl'],
350 private function getNormalizedCurrentPhpVersion(
$version)
353 $normalizedPhpVersion = $this->versionParser->normalize(
$version);
354 }
catch (\UnexpectedValueException $e) {
355 $prettyVersion = preg_replace(
'#^([^~+-]+).*$#',
'$1',
$version);
356 $normalizedPhpVersion = $this->versionParser->normalize($prettyVersion);
358 return $normalizedPhpVersion;
elseif(isset( $params[ 'redirect_parent']))
const RESPONSE_TYPE_SUCCESS
const RESPONSE_TYPE_ERROR
__construct(ComposerInformation $composerInformation, PhpInformation $phpInformation, VersionParser $versionParser, DataSize $dataSize)