Skip to content
Requirements checker
PHP Hack
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
src Add code Jul 18, 2019
tests Add code Jul 18, 2019
.gitattributes Initial commit Jul 18, 2019
.gitignore
.scrutinizer.yml Initial commit Jul 18, 2019
.styleci.yml Initial commit Jul 18, 2019
.travis.yml Initial commit Jul 18, 2019
CHANGELOG.md Initial commit Jul 18, 2019
LICENSE.md Initial commit Jul 18, 2019
README.md Add code Jul 18, 2019
composer.json fix php dependency condition (#2) Jul 19, 2019
phpunit.xml.dist Add code Jul 18, 2019

README.md

Yii Requirements Checker


The package allows to check if a certain set of defined requirements is met.

Latest Stable Version Total Downloads Build Status Scrutinizer Code Quality Code Coverage

General usage

Requirements checker could be used either from web or from command line. Create requirements.php:

<?php
require_once('/path/to/requirements/RequirementsChecker.php');

$config = array(
    array(
        'name' => 'PHP version',
        'mandatory' => true,
        'condition' => version_compare(PHP_VERSION, '7.2.0', '>='),
        'by' => '<a href="http://www.yiiframework.com">Yii Framework</a>',
        'memo' => 'PHP 7.2.0 or higher is required.',
    ),
    array(
        'name' => 'PDO MySQL extension',
        'mandatory' => false,
        'condition' => extension_loaded('pdo_mysql'),
        'by' => 'All DB-related classes',
        'memo' => 'Required for MySQL database.',
    ),
    array(
        'name' => 'Intl extension',
        'mandatory' => false,
        'condition' => $this->checkPhpExtensionVersion('intl', '1.0.2', '>='),
        'by' => '<a href="https://secure.php.net/manual/en/book.intl.php">Internationalization</a> support',
        'memo' => 'PHP Intl extension 1.0.2 or higher is required.'
    ),    
);

$requirementsChecker = new RequirementsChecker();

$result = $requirementsChecker->checkYii()->check($config)->getResult();
$requirementsChecker->render();
exit($result['summary']['errors'] === 0 ? 0 : 1);

Now it could be either put to webroot or executed as php requirements.php.

Note that the code above uses PHP 4. That is done on purpose so the checker could be executed in a very old setups and tell that upgrade should be done.

You can’t perform that action at this time.