2013-05-24 22:14:49 +08: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 :
2016-11-23 17:57:10 +08:00
* ln ../ requirements . php requirements . php
2013-05-24 22:14:49 +08:00
*/
// you may need to adjust this path to the correct Yii framework path
2017-10-30 16:33:22 +08:00
// uncomment and adjust the following line if Yii is not located at the default path
//$frameworkPath = dirname(__FILE__) . '/vendor/yiisoft/yii2';
if ( ! isset ( $frameworkPath )) {
2019-03-24 21:32:05 +08:00
$searchPaths = array (
2017-10-30 16:33:22 +08:00
dirname ( __FILE__ ) . '/vendor/yiisoft/yii2' ,
dirname ( __FILE__ ) . '/../vendor/yiisoft/yii2' ,
2019-03-24 21:32:05 +08:00
);
2017-10-30 16:33:22 +08:00
foreach ( $searchPaths as $path ) {
if ( is_dir ( $path )) {
$frameworkPath = $path ;
break ;
}
}
}
2013-05-26 07:46:39 +08:00
2017-10-30 16:42:15 +08:00
if ( ! isset ( $frameworkPath ) || ! is_dir ( $frameworkPath )) {
$message = " <h1>Error</h1> \n \n "
. " <p><strong>The path to yii framework seems to be incorrect.</strong></p> \n "
. '<p>You need to install Yii framework via composer or adjust the framework path in file <abbr title="' . __FILE__ . '">' . basename ( __FILE__ ) . " </abbr>.</p> \n "
. '<p>Please refer to the <abbr title="' . dirname ( __FILE__ ) . " /README.md \" >README</abbr> on how to install Yii.</p> \n " ;
if ( ! empty ( $_SERVER [ 'argv' ])) {
// do not print HTML when used in console mode
echo strip_tags ( $message );
} else {
echo $message ;
}
exit ( 1 );
2013-05-26 07:46:39 +08:00
}
2013-05-24 22:14:49 +08:00
require_once ( $frameworkPath . '/requirements/YiiRequirementChecker.php' );
$requirementsChecker = new YiiRequirementChecker ();
2014-10-19 05:22:26 +08:00
$gdMemo = $imagickMemo = 'Either GD PHP extension with FreeType support or ImageMagick PHP extension with PNG support is required for image CAPTCHA.' ;
$gdOK = $imagickOK = false ;
if ( extension_loaded ( 'imagick' )) {
$imagick = new Imagick ();
$imagickFormats = $imagick -> queryFormats ( 'PNG' );
if ( in_array ( 'PNG' , $imagickFormats )) {
$imagickOK = true ;
} else {
$imagickMemo = 'Imagick extension should be installed with PNG support in order to be used for image CAPTCHA.' ;
}
}
if ( extension_loaded ( 'gd' )) {
$gdInfo = gd_info ();
if ( ! empty ( $gdInfo [ 'FreeType Support' ])) {
$gdOK = true ;
} else {
$gdMemo = 'GD extension should be installed with FreeType support in order to be used for image CAPTCHA.' ;
}
}
2013-05-24 22:14:49 +08:00
/**
* Adjust requirements according to your application specifics .
*/
2013-12-31 18:02:32 +08:00
$requirements = array (
2014-03-16 12:46:16 +08:00
// Database :
array (
'name' => 'PDO extension' ,
'mandatory' => true ,
'condition' => extension_loaded ( 'pdo' ),
2014-04-10 12:05:05 +08:00
'by' => 'All DB-related classes' ,
2014-03-16 12:46:16 +08:00
),
array (
'name' => 'PDO SQLite extension' ,
'mandatory' => false ,
'condition' => extension_loaded ( 'pdo_sqlite' ),
2014-04-10 12:05:05 +08:00
'by' => 'All DB-related classes' ,
2014-03-16 12:46:16 +08:00
'memo' => 'Required for SQLite database.' ,
),
array (
'name' => 'PDO MySQL extension' ,
'mandatory' => false ,
'condition' => extension_loaded ( 'pdo_mysql' ),
2014-04-10 12:05:05 +08:00
'by' => 'All DB-related classes' ,
2014-03-16 12:46:16 +08:00
'memo' => 'Required for MySQL database.' ,
),
array (
'name' => 'PDO PostgreSQL extension' ,
'mandatory' => false ,
'condition' => extension_loaded ( 'pdo_pgsql' ),
2014-04-10 12:05:05 +08:00
'by' => 'All DB-related classes' ,
2014-03-16 12:46:16 +08:00
'memo' => 'Required for PostgreSQL database.' ,
),
// Cache :
array (
'name' => 'Memcache extension' ,
'mandatory' => false ,
'condition' => extension_loaded ( 'memcache' ) || extension_loaded ( 'memcached' ),
2014-04-10 12:05:05 +08: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 12:46:16 +08:00
),
2014-10-19 05:22:26 +08:00
// CAPTCHA:
array (
'name' => 'GD PHP extension with FreeType support' ,
'mandatory' => false ,
'condition' => $gdOK ,
'by' => '<a href="http://www.yiiframework.com/doc-2.0/yii-captcha-captcha.html">Captcha</a>' ,
'memo' => $gdMemo ,
),
array (
'name' => 'ImageMagick PHP extension with PNG support' ,
'mandatory' => false ,
'condition' => $imagickOK ,
'by' => '<a href="http://www.yiiframework.com/doc-2.0/yii-captcha-captcha.html">Captcha</a>' ,
'memo' => $imagickMemo ,
),
2014-03-16 12:46:16 +08:00
// 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 ,
2015-09-25 19:54:10 +08:00
'condition' => strlen ( ini_get ( 'SMTP' )) > 0 ,
2014-03-16 12:46:16 +08:00
'by' => 'Email sending' ,
'memo' => 'PHP mail SMTP server required' ,
),
2013-12-31 18:02:32 +08:00
);
2015-09-25 19:54:10 +08:00
// OPcache check
if ( ! version_compare ( phpversion (), '5.5' , '>=' )) {
$requirements [] = array (
'name' => 'APC extension' ,
'mandatory' => false ,
'condition' => extension_loaded ( 'apc' ),
'by' => '<a href="http://www.yiiframework.com/doc-2.0/yii-caching-apccache.html">ApcCache</a>' ,
);
}
2019-03-07 01:01:30 +08:00
$result = $requirementsChecker -> checkYii () -> check ( $requirements ) -> getResult ();
$requirementsChecker -> render ();
exit ( $result [ 'summary' ][ 'errors' ] === 0 ? 0 : 1 );