|
1 <?php |
|
2 |
|
3 if (!$iniPath = get_cfg_var('cfg_file_path')) { |
|
4 $iniPath = 'WARNING: not using a php.ini file'; |
|
5 } |
|
6 |
|
7 echo "********************************\n"; |
|
8 echo "* *\n"; |
|
9 echo "* Symfony requirements check *\n"; |
|
10 echo "* *\n"; |
|
11 echo "********************************\n\n"; |
|
12 echo sprintf("php.ini used by PHP: %s\n\n", $iniPath); |
|
13 |
|
14 echo "** WARNING **\n"; |
|
15 echo "* The PHP CLI can use a different php.ini file\n"; |
|
16 echo "* than the one used with your web server.\n"; |
|
17 if ('\\' == DIRECTORY_SEPARATOR) { |
|
18 echo "* (especially on the Windows platform)\n"; |
|
19 } |
|
20 echo "* If this is the case, please ALSO launch this\n"; |
|
21 echo "* utility from your web server.\n"; |
|
22 echo "** WARNING **\n"; |
|
23 |
|
24 // mandatory |
|
25 echo_title("Mandatory requirements"); |
|
26 check(version_compare(phpversion(), '5.3.2', '>='), sprintf('Checking that PHP version is at least 5.3.2 (%s installed)', phpversion()), 'Install PHP 5.3.2 or newer (current version is '.phpversion(), true); |
|
27 check(ini_get('date.timezone'), 'Checking that the "date.timezone" setting is set', 'Set the "date.timezone" setting in php.ini (like Europe/Paris)', true); |
|
28 check(is_writable(__DIR__.'/../app/cache'), sprintf('Checking that app/cache/ directory is writable'), 'Change the permissions of the app/cache/ directory so that the web server can write in it', true); |
|
29 check(is_writable(__DIR__.'/../app/logs'), sprintf('Checking that the app/logs/ directory is writable'), 'Change the permissions of the app/logs/ directory so that the web server can write in it', true); |
|
30 check(function_exists('json_encode'), 'Checking that the json_encode() is available', 'Install and enable the json extension', true); |
|
31 check(class_exists('SQLite3') || in_array('sqlite', PDO::getAvailableDrivers()), 'Checking that the SQLite3 or PDO_SQLite extension is available', 'Install and enable the SQLite3 or PDO_SQLite extension.', true); |
|
32 check(function_exists('session_start'), 'Checking that the session_start() is available', 'Install and enable the session extension', true); |
|
33 check(function_exists('ctype_alpha'), 'Checking that the ctype_alpha() is available', 'Install and enable the ctype extension', true); |
|
34 check(!(function_exists('apc_store') && ini_get('apc.enabled')) || version_compare(phpversion('apc'), '3.0.17', '>='), 'Checking that the APC version is at least 3.0.17', 'Upgrade your APC extension (3.0.17+)', true); |
|
35 |
|
36 // warnings |
|
37 echo_title("Optional checks"); |
|
38 check(class_exists('DomDocument'), 'Checking that the PHP-XML module is installed', 'Install and enable the php-xml module', false); |
|
39 check(defined('LIBXML_COMPACT'), 'Checking that the libxml version is at least 2.6.21', 'Upgrade your php-xml module with a newer libxml', false); |
|
40 check(function_exists('token_get_all'), 'Checking that the token_get_all() function is available', 'Install and enable the Tokenizer extension (highly recommended)', false); |
|
41 check(function_exists('mb_strlen'), 'Checking that the mb_strlen() function is available', 'Install and enable the mbstring extension', false); |
|
42 check(function_exists('iconv'), 'Checking that the iconv() function is available', 'Install and enable the iconv extension', false); |
|
43 check(function_exists('utf8_decode'), 'Checking that the utf8_decode() is available', 'Install and enable the XML extension', false); |
|
44 if (PHP_OS != 'WINNT') { |
|
45 check(function_exists('posix_isatty'), 'Checking that the posix_isatty() is available', 'Install and enable the php_posix extension (used to colorized the CLI output)', false); |
|
46 } |
|
47 check(class_exists('Locale'), 'Checking that the intl extension is available', 'Install and enable the intl extension (used for validators)', false); |
|
48 if (class_exists('Locale')) { |
|
49 $version = ''; |
|
50 |
|
51 if (defined('INTL_ICU_VERSION')) { |
|
52 $version = INTL_ICU_VERSION; |
|
53 } else { |
|
54 $reflector = new \ReflectionExtension('intl'); |
|
55 |
|
56 ob_start(); |
|
57 $reflector->info(); |
|
58 $output = strip_tags(ob_get_clean()); |
|
59 |
|
60 preg_match('/^ICU version +(?:=> )?(.*)$/m', $output, $matches); |
|
61 $version = $matches[1]; |
|
62 } |
|
63 |
|
64 check(version_compare($version, '4.0', '>='), 'Checking that the intl ICU version is at least 4+', 'Upgrade your intl extension with a newer ICU version (4+)', false); |
|
65 } |
|
66 |
|
67 $accelerator = |
|
68 (function_exists('apc_store') && ini_get('apc.enabled')) |
|
69 || |
|
70 function_exists('eaccelerator_put') && ini_get('eaccelerator.enable') |
|
71 || |
|
72 function_exists('xcache_set') |
|
73 ; |
|
74 check($accelerator, 'Checking that a PHP accelerator is installed', 'Install a PHP accelerator like APC (highly recommended)', false); |
|
75 |
|
76 check(!ini_get('short_open_tag'), 'Checking that php.ini has short_open_tag set to off', 'Set short_open_tag to off in php.ini', false); |
|
77 check(!ini_get('magic_quotes_gpc'), 'Checking that php.ini has magic_quotes_gpc set to off', 'Set magic_quotes_gpc to off in php.ini', false); |
|
78 check(!ini_get('register_globals'), 'Checking that php.ini has register_globals set to off', 'Set register_globals to off in php.ini', false); |
|
79 check(!ini_get('session.auto_start'), 'Checking that php.ini has session.auto_start set to off', 'Set session.auto_start to off in php.ini', false); |
|
80 |
|
81 echo_title("Optional checks (Doctrine)"); |
|
82 |
|
83 check(class_exists('PDO'), 'Checking that PDO is installed', 'Install PDO (mandatory for Doctrine)', false); |
|
84 if (class_exists('PDO')) { |
|
85 $drivers = PDO::getAvailableDrivers(); |
|
86 check(count($drivers), 'Checking that PDO has some drivers installed: '.implode(', ', $drivers), 'Install PDO drivers (mandatory for Doctrine)'); |
|
87 } |
|
88 |
|
89 /** |
|
90 * Checks a configuration. |
|
91 */ |
|
92 function check($boolean, $message, $help = '', $fatal = false) |
|
93 { |
|
94 echo $boolean ? " OK " : sprintf("\n\n[[%s]] ", $fatal ? ' ERROR ' : 'WARNING'); |
|
95 echo sprintf("$message%s\n", $boolean ? '' : ': FAILED'); |
|
96 |
|
97 if (!$boolean) { |
|
98 echo " *** $help ***\n"; |
|
99 if ($fatal) { |
|
100 exit("You must fix this problem before resuming the check.\n"); |
|
101 } |
|
102 } |
|
103 } |
|
104 |
|
105 function echo_title($title) |
|
106 { |
|
107 echo "\n** $title **\n\n"; |
|
108 } |