OSDN Git Service

Добавлен тест модели размещений.
[invent/invent.git] / requirements.php
1 <?php
2 /**
3  * Application requirement checker script.
4  *
5  * In order to run this script use the following console command:
6  * php requirements.php
7  *
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
11  */
12
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';
16
17
18 if (!isset($frameworkPath)) {
19     $searchPaths = array(
20         dirname(__FILE__) . '/vendor/yiisoft/yii2',
21         dirname(__FILE__) . '/../vendor/yiisoft/yii2',
22     );
23     foreach ($searchPaths as $path) {
24         if (is_dir($path)) {
25             $frameworkPath = $path;
26             break;
27         }
28     }
29 }
30
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";
36
37     if (!empty($_SERVER['argv'])) {
38         // do not print HTML when used in console mode
39         echo strip_tags($message);
40     } else {
41         echo $message;
42     }
43     exit(1);
44 }
45
46 require_once($frameworkPath . '/requirements/YiiRequirementChecker.php');
47 $requirementsChecker = new YiiRequirementChecker();
48
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;
51
52 if (extension_loaded('imagick')) {
53     $imagick = new Imagick();
54     $imagickFormats = $imagick->queryFormats('PNG');
55     if (in_array('PNG', $imagickFormats)) {
56         $imagickOK = true;
57     } else {
58         $imagickMemo = 'Imagick extension should be installed with PNG support in order to be used for image CAPTCHA.';
59     }
60 }
61
62 if (extension_loaded('gd')) {
63     $gdInfo = gd_info();
64     if (!empty($gdInfo['FreeType Support'])) {
65         $gdOK = true;
66     } else {
67         $gdMemo = 'GD extension should be installed with FreeType support in order to be used for image CAPTCHA.';
68     }
69 }
70
71 /**
72  * Adjust requirements according to your application specifics.
73  */
74 $requirements = array(
75     // Database :
76     array(
77         'name' => 'PDO extension',
78         'mandatory' => true,
79         'condition' => extension_loaded('pdo'),
80         'by' => 'All DB-related classes',
81     ),
82     array(
83         'name' => 'PDO SQLite extension',
84         'mandatory' => false,
85         'condition' => extension_loaded('pdo_sqlite'),
86         'by' => 'All DB-related classes',
87         'memo' => 'Required for SQLite database.',
88     ),
89     array(
90         'name' => 'PDO MySQL extension',
91         'mandatory' => false,
92         'condition' => extension_loaded('pdo_mysql'),
93         'by' => 'All DB-related classes',
94         'memo' => 'Required for MySQL database.',
95     ),
96     array(
97         'name' => 'PDO PostgreSQL extension',
98         'mandatory' => false,
99         'condition' => extension_loaded('pdo_pgsql'),
100         'by' => 'All DB-related classes',
101         'memo' => 'Required for PostgreSQL database.',
102     ),
103     // Cache :
104     array(
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>.' : ''
110     ),
111     // CAPTCHA:
112     array(
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>',
117         'memo' => $gdMemo,
118     ),
119     array(
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,
125     ),
126     // PHP ini :
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',
133     ),
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',
140     ),
141     'phpSmtp' => array(
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',
147     ),
148 );
149
150 // OPcache check
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>',
157     );
158 }
159
160 $result = $requirementsChecker->checkYii()->check($requirements)->getResult();
161 $requirementsChecker->render();
162 exit($result['summary']['errors'] === 0 ? 0 : 1);