check_configuration.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. function is_cli()
  3. {
  4. return !isset($_SERVER['HTTP_HOST']);
  5. }
  6. /**
  7. * Checks a configuration.
  8. */
  9. function check($boolean, $message, $help = '', $fatal = false)
  10. {
  11. echo $boolean ? " OK " : sprintf("[[%s]] ", $fatal ? ' ERROR ' : 'WARNING');
  12. echo "$message\n";
  13. if (!$boolean)
  14. {
  15. echo " *** $help ***\n";
  16. if ($fatal)
  17. {
  18. die("You must fix this problem before resuming the check.\n");
  19. }
  20. }
  21. }
  22. /**
  23. * Gets the php.ini path used by the current PHP interpretor.
  24. *
  25. * @return string the php.ini path
  26. */
  27. function get_ini_path()
  28. {
  29. if ($path = get_cfg_var('cfg_file_path'))
  30. {
  31. return $path;
  32. }
  33. return 'WARNING: not using a php.ini file';
  34. }
  35. if (!is_cli())
  36. {
  37. echo '<html><body><pre>';
  38. }
  39. echo "********************************\n";
  40. echo "* *\n";
  41. echo "* symfony requirements check *\n";
  42. echo "* *\n";
  43. echo "********************************\n\n";
  44. echo sprintf("php.ini used by PHP: %s\n\n", get_ini_path());
  45. if (is_cli())
  46. {
  47. echo "** WARNING **\n";
  48. echo "* The PHP CLI can use a different php.ini file\n";
  49. echo "* than the one used with your web server.\n";
  50. if ('\\' == DIRECTORY_SEPARATOR)
  51. {
  52. echo "* (especially on the Windows platform)\n";
  53. }
  54. echo "* If this is the case, please launch this\n";
  55. echo "* utility from your web server.\n";
  56. echo "** WARNING **\n";
  57. }
  58. // mandatory
  59. echo "\n** Mandatory requirements **\n\n";
  60. check(version_compare(phpversion(), '5.1.3', '>='), 'requires PHP >= 5.1.3', 'Current version is '.phpversion(), true);
  61. check(!ini_get('zend.ze1_compatibility_mode'), 'php.ini: requires zend.ze1_compatibility_mode set to off', sprintf('Set it to off in php.ini (%s)', get_ini_path()), true);
  62. // warnings
  63. echo "\n** Optional checks **\n\n";
  64. check(function_exists('token_get_all'), 'can use token_get_all()', 'Install token_get_all() function (highly recommended)', false);
  65. check(function_exists('mb_strlen'), 'can use mb_strlen()', 'Install mb_strlen() function', false);
  66. check(function_exists('iconv'), 'can use iconv()', 'Install iconv() function', false);
  67. check(function_exists('utf8_decode'), 'can use utf8_decode()', 'Install utf8_decode() function', false);
  68. $accelerator =
  69. (function_exists('apc_store') && ini_get('apc.enabled'))
  70. ||
  71. function_exists('eaccelerator_put') && ini_get('eaccelerator.enable')
  72. ||
  73. function_exists('xcache_set')
  74. ;
  75. check($accelerator, 'has a PHP accelerator', 'Install a PHP accelerator (highly recommended)', false);
  76. check(!ini_get('magic_quotes_gpc'), 'php.ini: magic_quotes_gpc set to off', 'Set it to off in php.ini', false);
  77. check(!ini_get('register_globals'), 'php.ini: register_globals set to off', 'Set it to off in php.ini', false);
  78. check(!ini_get('session.auto_start'), 'php.ini: session.auto_start set to off', 'Set it to off in php.ini', false);
  79. check(version_compare(phpversion(), '5.2.9', '!='), 'PHP version is not 5.2.9', 'PHP 5.2.9 broke array_unique() and sfToolkit::arrayDeepMerge(). Use 5.2.10 instead [Ticket #6211]', false);
  80. if (!is_cli())
  81. {
  82. echo '</pre></body></html>';
  83. }