mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-17 14:57:23 +08:00
Reverted 5.4 enhancements on requirements checked to be able to run it on lower PHP versions
This commit is contained in:
@@ -19,15 +19,15 @@ if (version_compare(PHP_VERSION, '4.3', '<')) {
|
||||
* ~~~php
|
||||
* require_once('path/to/YiiRequirementChecker.php');
|
||||
* $requirementsChecker = new YiiRequirementChecker();
|
||||
* $requirements = [
|
||||
* [
|
||||
* $requirements = array(
|
||||
* array(
|
||||
* 'name' => 'PHP Some Extension',
|
||||
* 'mandatory' => true,
|
||||
* 'condition' => extension_loaded('some_extension'),
|
||||
* 'by' => 'Some application feature',
|
||||
* 'memo' => 'PHP extension "some_extension" required',
|
||||
* ],
|
||||
* ];
|
||||
* ),
|
||||
* );
|
||||
* $requirementsChecker->checkYii()->check($requirements)->render();
|
||||
* ~~~
|
||||
*
|
||||
@@ -38,12 +38,12 @@ if (version_compare(PHP_VERSION, '4.3', '<')) {
|
||||
* For example:
|
||||
*
|
||||
* ~~~
|
||||
* $requirements = [
|
||||
* [
|
||||
* $requirements = array(
|
||||
* array(
|
||||
* 'name' => 'Upload max file size',
|
||||
* 'condition' => 'eval:$this->checkUploadMaxFileSize("5M")',
|
||||
* ],
|
||||
* ];
|
||||
* ),
|
||||
* );
|
||||
* ~~~
|
||||
*
|
||||
* Note: this class definition does not match ordinary Yii style, because it should match PHP 4.3
|
||||
@@ -74,14 +74,14 @@ class YiiRequirementChecker
|
||||
$this->usageError('Requirements must be an array, "' . gettype($requirements) . '" has been given!');
|
||||
}
|
||||
if (!isset($this->result) || !is_array($this->result)) {
|
||||
$this->result = [
|
||||
'summary' => [
|
||||
$this->result = array(
|
||||
'summary' => array(
|
||||
'total' => 0,
|
||||
'errors' => 0,
|
||||
'warnings' => 0,
|
||||
],
|
||||
'requirements' => [],
|
||||
];
|
||||
),
|
||||
'requirements' => array(),
|
||||
);
|
||||
}
|
||||
foreach ($requirements as $key => $rawRequirement) {
|
||||
$requirement = $this->normalizeRequirement($rawRequirement, $key);
|
||||
@@ -118,21 +118,21 @@ class YiiRequirementChecker
|
||||
* Return the check results.
|
||||
* @return array|null check results in format:
|
||||
* <code>
|
||||
* [
|
||||
* 'summary' => [
|
||||
* array(
|
||||
* 'summary' => array(
|
||||
* 'total' => total number of checks,
|
||||
* 'errors' => number of errors,
|
||||
* 'warnings' => number of warnings,
|
||||
* ],
|
||||
* 'requirements' => [
|
||||
* [
|
||||
* ),
|
||||
* 'requirements' => array(
|
||||
* array(
|
||||
* ...
|
||||
* 'error' => is there an error,
|
||||
* 'warning' => is there a warning,
|
||||
* ],
|
||||
* ),
|
||||
* ...
|
||||
* ],
|
||||
* ]
|
||||
* ),
|
||||
* )
|
||||
* </code>
|
||||
*/
|
||||
function getResult()
|
||||
|
||||
@@ -1,44 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* These are the Yii core requirements for the [[YiiRequirementChecker]] instance.
|
||||
* These are the Yii core requirements for the array(array(YiiRequirementChecker)) instance.
|
||||
* These requirements are mandatory for any Yii application.
|
||||
*
|
||||
* @var $this YiiRequirementChecker
|
||||
*/
|
||||
return [
|
||||
[
|
||||
return array(
|
||||
array(
|
||||
'name' => 'PHP version',
|
||||
'mandatory' => true,
|
||||
'condition' => version_compare(PHP_VERSION, '5.4.0', '>='),
|
||||
'by' => '<a href="http://www.yiiframework.com">Yii Framework</a>',
|
||||
'memo' => 'PHP 5.4.0 or higher is required.',
|
||||
],
|
||||
[
|
||||
),
|
||||
array(
|
||||
'name' => 'Reflection extension',
|
||||
'mandatory' => true,
|
||||
'condition' => class_exists('Reflection', false),
|
||||
'by' => '<a href="http://www.yiiframework.com">Yii Framework</a>',
|
||||
],
|
||||
[
|
||||
),
|
||||
array(
|
||||
'name' => 'PCRE extension',
|
||||
'mandatory' => true,
|
||||
'condition' => extension_loaded('pcre'),
|
||||
'by' => '<a href="http://www.yiiframework.com">Yii Framework</a>',
|
||||
],
|
||||
[
|
||||
),
|
||||
array(
|
||||
'name' => 'SPL extension',
|
||||
'mandatory' => true,
|
||||
'condition' => extension_loaded('SPL'),
|
||||
'by' => '<a href="http://www.yiiframework.com">Yii Framework</a>',
|
||||
],
|
||||
[
|
||||
),
|
||||
array(
|
||||
'name' => 'MBString extension',
|
||||
'mandatory' => true,
|
||||
'condition' => extension_loaded('mbstring'),
|
||||
'by' => '<a href="http://www.php.net/manual/en/book.mbstring.php">Multibyte string</a> processing',
|
||||
'memo' => 'Required for multibyte encoding string processing.'
|
||||
],
|
||||
[
|
||||
),
|
||||
array(
|
||||
'name' => 'Intl extension',
|
||||
'mandatory' => false,
|
||||
'condition' => $this->checkPhpExtensionVersion('intl', '1.0.2', '>='),
|
||||
@@ -46,5 +46,5 @@ return [
|
||||
'memo' => 'PHP Intl extension 1.0.2 or higher is required when you want to use advanced parameters formatting
|
||||
in <code>\Yii::t()</code>, <abbr title="Internationalized domain names">IDN</abbr>-feature of
|
||||
<code>EmailValidator</code> or <code>UrlValidator</code> or the <code>yii\i18n\Formatter</code> class.'
|
||||
],
|
||||
];
|
||||
),
|
||||
);
|
||||
|
||||
@@ -52,18 +52,18 @@
|
||||
<table class="table table-bordered">
|
||||
<tr><th>Name</th><th>Result</th><th>Required By</th><th>Memo</th></tr>
|
||||
<?php foreach($requirements as $requirement): ?>
|
||||
<tr class="<?= $requirement['condition'] ? 'success' : ($requirement['mandatory'] ? 'error' : 'warning') ?>">
|
||||
<tr class="<?php echo $requirement['condition'] ? 'success' : ($requirement['mandatory'] ? 'error' : 'warning') ?>">
|
||||
<td>
|
||||
<?= $requirement['name'] ?>
|
||||
<?php echo $requirement['name'] ?>
|
||||
</td>
|
||||
<td>
|
||||
<span class="result"><?= $requirement['condition'] ? 'Passed' : ($requirement['mandatory'] ? 'Failed' : 'Warning') ?></span>
|
||||
<span class="result"><?php echo $requirement['condition'] ? 'Passed' : ($requirement['mandatory'] ? 'Failed' : 'Warning') ?></span>
|
||||
</td>
|
||||
<td>
|
||||
<?= $requirement['by'] ?>
|
||||
<?php echo $requirement['by'] ?>
|
||||
</td>
|
||||
<td>
|
||||
<?= $requirement['memo'] ?>
|
||||
<?php echo $requirement['memo'] ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
@@ -74,7 +74,7 @@
|
||||
<hr>
|
||||
|
||||
<div class="footer">
|
||||
<p>Server: <?= $this->getServerInfo() . ' ' . $this->getNowDate() ?></p>
|
||||
<p>Server: <?php echo $this->getServerInfo() . ' ' . $this->getNowDate() ?></p>
|
||||
<p>Powered by <a href="http://www.yiiframework.com/" rel="external">Yii Framework</a></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user