check.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. if (!$iniPath = get_cfg_var('cfg_file_path')) {
  3. $iniPath = 'WARNING: not using a php.ini file';
  4. }
  5. echo "********************************\n";
  6. echo "* *\n";
  7. echo "* Symfony requirements check *\n";
  8. echo "* *\n";
  9. echo "********************************\n\n";
  10. echo sprintf("php.ini used by PHP: %s\n\n", $iniPath);
  11. echo "** WARNING **\n";
  12. echo "* The PHP CLI can use a different php.ini file\n";
  13. echo "* than the one used with your web server.\n";
  14. if ('\\' == DIRECTORY_SEPARATOR) {
  15. echo "* (especially on the Windows platform)\n";
  16. }
  17. echo "* If this is the case, please ALSO launch this\n";
  18. echo "* utility from your web server.\n";
  19. echo "** WARNING **\n";
  20. // mandatory
  21. echo_title("Mandatory requirements");
  22. 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);
  23. 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);
  24. 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);
  25. 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);
  26. check(function_exists('json_encode'), 'Checking that the json_encode() is available', 'Install and enable the json extension', true);
  27. // warnings
  28. echo_title("Optional checks");
  29. check(class_exists('DomDocument'), 'Checking that the PHP-XML module is installed', 'Install and enable the php-xml module', false);
  30. 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);
  31. check(function_exists('token_get_all'), 'Checking that the token_get_all() function is available', 'Install and enable the Tokenizer extension (highly recommended)', false);
  32. check(function_exists('mb_strlen'), 'Checking that the mb_strlen() function is available', 'Install and enable the mbstring extension', false);
  33. check(function_exists('iconv'), 'Checking that the iconv() function is available', 'Install and enable the iconv extension', false);
  34. check(function_exists('utf8_decode'), 'Checking that the utf8_decode() is available', 'Install and enable the XML extension', false);
  35. 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);
  36. check(class_exists('Locale'), 'Checking that the intl extension is available', 'Install and enable the intl extension (used for validators)', false);
  37. $accelerator =
  38. (function_exists('apc_store') && ini_get('apc.enabled'))
  39. ||
  40. function_exists('eaccelerator_put') && ini_get('eaccelerator.enable')
  41. ||
  42. function_exists('xcache_set')
  43. ;
  44. check($accelerator, 'Checking that a PHP accelerator is installed', 'Install a PHP accelerator like APC (highly recommended)', false);
  45. 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);
  46. 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);
  47. check(!ini_get('register_globals'), 'Checking that php.ini has register_globals set to off', 'Set register_globals to off in php.ini', false);
  48. 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);
  49. echo_title("Optional checks (Doctrine)");
  50. check(class_exists('PDO'), 'Checking that PDO is installed', 'Install PDO (mandatory for Doctrine)', false);
  51. if (class_exists('PDO')) {
  52. $drivers = PDO::getAvailableDrivers();
  53. check(count($drivers), 'Checking that PDO has some drivers installed: '.implode(', ', $drivers), 'Install PDO drivers (mandatory for Doctrine)');
  54. }
  55. /**
  56. * Checks a configuration.
  57. */
  58. function check($boolean, $message, $help = '', $fatal = false)
  59. {
  60. echo $boolean ? " OK " : sprintf("\n\n[[%s]] ", $fatal ? ' ERROR ' : 'WARNING');
  61. echo sprintf("$message%s\n", $boolean ? '' : ': FAILED');
  62. if (!$boolean) {
  63. echo " *** $help ***\n";
  64. if ($fatal) {
  65. die("You must fix this problem before resuming the check.\n");
  66. }
  67. }
  68. }
  69. function echo_title($title)
  70. {
  71. echo "\n** $title **\n\n";
  72. }