3 * Application requirement checker script.
5 * In order to run this script use the following console command:
8 * In order to run this script from the web, you should copy it to the web root.
9 * If you are using Linux you can create a hard link instead, using the following command:
10 * ln ../requirements.php requirements.php
13 // you may need to adjust this path to the correct Yii framework path
14 // uncomment and adjust the following line if Yii is not located at the default path
15 //$frameworkPath = dirname(__FILE__) . '/vendor/yiisoft/yii2';
18 if (!isset($frameworkPath)) {
20 dirname(__FILE__) . '/vendor/yiisoft/yii2',
21 dirname(__FILE__) . '/../vendor/yiisoft/yii2',
23 foreach ($searchPaths as $path) {
25 $frameworkPath = $path;
31 if (!isset($frameworkPath) || !is_dir($frameworkPath)) {
32 $message = "<h1>Error</h1>\n\n"
33 . "<p><strong>The path to yii framework seems to be incorrect.</strong></p>\n"
34 . '<p>You need to install Yii framework via composer or adjust the framework path in file <abbr title="' . __FILE__ . '">' . basename(__FILE__) . "</abbr>.</p>\n"
35 . '<p>Please refer to the <abbr title="' . dirname(__FILE__) . "/README.md\">README</abbr> on how to install Yii.</p>\n";
37 if (!empty($_SERVER['argv'])) {
38 // do not print HTML when used in console mode
39 echo strip_tags($message);
46 require_once($frameworkPath . '/requirements/YiiRequirementChecker.php');
47 $requirementsChecker = new YiiRequirementChecker();
49 $gdMemo = $imagickMemo = 'Either GD PHP extension with FreeType support or ImageMagick PHP extension with PNG support is required for image CAPTCHA.';
50 $gdOK = $imagickOK = false;
52 if (extension_loaded('imagick')) {
53 $imagick = new Imagick();
54 $imagickFormats = $imagick->queryFormats('PNG');
55 if (in_array('PNG', $imagickFormats)) {
58 $imagickMemo = 'Imagick extension should be installed with PNG support in order to be used for image CAPTCHA.';
62 if (extension_loaded('gd')) {
64 if (!empty($gdInfo['FreeType Support'])) {
67 $gdMemo = 'GD extension should be installed with FreeType support in order to be used for image CAPTCHA.';
72 * Adjust requirements according to your application specifics.
74 $requirements = array(
77 'name' => 'PDO extension',
79 'condition' => extension_loaded('pdo'),
80 'by' => 'All DB-related classes',
83 'name' => 'PDO SQLite extension',
85 'condition' => extension_loaded('pdo_sqlite'),
86 'by' => 'All DB-related classes',
87 'memo' => 'Required for SQLite database.',
90 'name' => 'PDO MySQL extension',
92 'condition' => extension_loaded('pdo_mysql'),
93 'by' => 'All DB-related classes',
94 'memo' => 'Required for MySQL database.',
97 'name' => 'PDO PostgreSQL extension',
99 'condition' => extension_loaded('pdo_pgsql'),
100 'by' => 'All DB-related classes',
101 'memo' => 'Required for PostgreSQL database.',
105 'name' => 'Memcache extension',
106 'mandatory' => false,
107 'condition' => extension_loaded('memcache') || extension_loaded('memcached'),
108 'by' => '<a href="http://www.yiiframework.com/doc-2.0/yii-caching-memcache.html">MemCache</a>',
109 '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>.' : ''
113 'name' => 'GD PHP extension with FreeType support',
114 'mandatory' => false,
115 'condition' => $gdOK,
116 'by' => '<a href="http://www.yiiframework.com/doc-2.0/yii-captcha-captcha.html">Captcha</a>',
120 'name' => 'ImageMagick PHP extension with PNG support',
121 'mandatory' => false,
122 'condition' => $imagickOK,
123 'by' => '<a href="http://www.yiiframework.com/doc-2.0/yii-captcha-captcha.html">Captcha</a>',
124 'memo' => $imagickMemo,
127 'phpExposePhp' => array(
128 'name' => 'Expose PHP',
129 'mandatory' => false,
130 'condition' => $requirementsChecker->checkPhpIniOff("expose_php"),
131 'by' => 'Security reasons',
132 'memo' => '"expose_php" should be disabled at php.ini',
134 'phpAllowUrlInclude' => array(
135 'name' => 'PHP allow url include',
136 'mandatory' => false,
137 'condition' => $requirementsChecker->checkPhpIniOff("allow_url_include"),
138 'by' => 'Security reasons',
139 'memo' => '"allow_url_include" should be disabled at php.ini',
142 'name' => 'PHP mail SMTP',
143 'mandatory' => false,
144 'condition' => strlen(ini_get('SMTP')) > 0,
145 'by' => 'Email sending',
146 'memo' => 'PHP mail SMTP server required',
151 if (!version_compare(phpversion(), '5.5', '>=')) {
152 $requirements[] = array(
153 'name' => 'APC extension',
154 'mandatory' => false,
155 'condition' => extension_loaded('apc'),
156 'by' => '<a href="http://www.yiiframework.com/doc-2.0/yii-caching-apccache.html">ApcCache</a>',
160 $result = $requirementsChecker->checkYii()->check($requirements)->getResult();
161 $requirementsChecker->render();
162 exit($result['summary']['errors'] === 0 ? 0 : 1);