2013-05-24 10:14:49 -04:00
< ? php
/**
* Application requirement checker script .
*
* In order to run this script use the following console command :
* php requirements . php
*
* In order to run this script from the web , you should copy it to the web root .
* If you are using Linux you can create a hard link instead , using the following command :
* ln requirements . php ../ requirements . php
*/
// you may need to adjust this path to the correct Yii framework path
2014-01-11 09:52:43 +04:00
$frameworkPath = dirname ( __FILE__ ) . '/vendor/yiisoft/yii2' ;
2013-05-26 01:46:39 +02:00
if ( ! is_dir ( $frameworkPath )) {
2014-03-16 10:46:16 +06:00
echo '<h1>Error</h1>' ;
echo '<p><strong>The path to yii framework seems to be incorrect.</strong></p>' ;
echo '<p>You need to install Yii framework via composer or adjust the framework path in file <abbr title="' . __FILE__ . '">' . basename ( __FILE__ ) . '</abbr>.</p>' ;
echo '<p>Please refer to the <abbr title="' . dirname ( __FILE__ ) . '/README.md">README</abbr> on how to install Yii.</p>' ;
2013-05-26 01:46:39 +02:00
}
2013-05-24 10:14:49 -04:00
require_once ( $frameworkPath . '/requirements/YiiRequirementChecker.php' );
$requirementsChecker = new YiiRequirementChecker ();
/**
* Adjust requirements according to your application specifics .
*/
2013-12-31 11:02:32 +01:00
$requirements = array (
2014-03-16 10:46:16 +06:00
// Database :
array (
'name' => 'PDO extension' ,
'mandatory' => true ,
'condition' => extension_loaded ( 'pdo' ),
2014-04-10 00:05:05 -04:00
'by' => 'All DB-related classes' ,
2014-03-16 10:46:16 +06:00
),
array (
'name' => 'PDO SQLite extension' ,
'mandatory' => false ,
'condition' => extension_loaded ( 'pdo_sqlite' ),
2014-04-10 00:05:05 -04:00
'by' => 'All DB-related classes' ,
2014-03-16 10:46:16 +06:00
'memo' => 'Required for SQLite database.' ,
),
array (
'name' => 'PDO MySQL extension' ,
'mandatory' => false ,
'condition' => extension_loaded ( 'pdo_mysql' ),
2014-04-10 00:05:05 -04:00
'by' => 'All DB-related classes' ,
2014-03-16 10:46:16 +06:00
'memo' => 'Required for MySQL database.' ,
),
array (
'name' => 'PDO PostgreSQL extension' ,
'mandatory' => false ,
'condition' => extension_loaded ( 'pdo_pgsql' ),
2014-04-10 00:05:05 -04:00
'by' => 'All DB-related classes' ,
2014-03-16 10:46:16 +06:00
'memo' => 'Required for PostgreSQL database.' ,
),
// Cache :
array (
'name' => 'Memcache extension' ,
'mandatory' => false ,
'condition' => extension_loaded ( 'memcache' ) || extension_loaded ( 'memcached' ),
2014-04-10 00:05:05 -04:00
'by' => '<a href="http://www.yiiframework.com/doc-2.0/yii-caching-memcache.html">MemCache</a>' ,
'memo' => extension_loaded ( 'memcached' ) ? 'To use memcached set <a href="http://www.yiiframework.com/doc-2.0/yii-caching-memcache.html#$useMemcached-detail">MemCache::useMemcached</a> to <code>true</code>.' : ''
2014-03-16 10:46:16 +06:00
),
array (
'name' => 'APC extension' ,
'mandatory' => false ,
'condition' => extension_loaded ( 'apc' ),
2014-04-10 00:05:05 -04:00
'by' => '<a href="http://www.yiiframework.com/doc-2.0/yii-caching-apccache.html">ApcCache</a>' ,
2014-03-16 10:46:16 +06:00
),
// Additional PHP extensions :
array (
'name' => 'Mcrypt extension' ,
'mandatory' => false ,
'condition' => extension_loaded ( 'mcrypt' ),
2014-04-10 00:05:05 -04:00
'by' => '<a href="http://www.yiiframework.com/doc-2.0/yii-helpers-security.html">Security Helper</a>' ,
2014-03-16 10:46:16 +06:00
'memo' => 'Required by encrypt and decrypt methods.'
),
// PHP ini :
'phpSafeMode' => array (
'name' => 'PHP safe mode' ,
'mandatory' => false ,
'condition' => $requirementsChecker -> checkPhpIniOff ( " safe_mode " ),
'by' => 'File uploading and console command execution' ,
'memo' => '"safe_mode" should be disabled at php.ini' ,
),
'phpExposePhp' => array (
'name' => 'Expose PHP' ,
'mandatory' => false ,
'condition' => $requirementsChecker -> checkPhpIniOff ( " expose_php " ),
'by' => 'Security reasons' ,
'memo' => '"expose_php" should be disabled at php.ini' ,
),
'phpAllowUrlInclude' => array (
'name' => 'PHP allow url include' ,
'mandatory' => false ,
'condition' => $requirementsChecker -> checkPhpIniOff ( " allow_url_include " ),
'by' => 'Security reasons' ,
'memo' => '"allow_url_include" should be disabled at php.ini' ,
),
'phpSmtp' => array (
'name' => 'PHP mail SMTP' ,
'mandatory' => false ,
'condition' => strlen ( ini_get ( 'SMTP' )) > 0 ,
'by' => 'Email sending' ,
'memo' => 'PHP mail SMTP server required' ,
),
2013-12-31 11:02:32 +01:00
);
2013-05-24 10:14:49 -04:00
$requirementsChecker -> checkYii () -> check ( $requirements ) -> render ();