config.php 8.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <?php
  2. if (!isset($_SERVER['HTTP_HOST'])) {
  3. exit('This script cannot be run from the CLI. Run it from a browser.');
  4. }
  5. if (!in_array(@$_SERVER['REMOTE_ADDR'], array(
  6. '127.0.0.1',
  7. '::1',
  8. ))) {
  9. header('HTTP/1.0 403 Forbidden');
  10. exit('This script is only accessible from localhost.');
  11. }
  12. $majorProblems = array();
  13. $minorProblems = array();
  14. $phpini = false;
  15. // minimum
  16. if (!version_compare(phpversion(), '5.3.2', '>=')) {
  17. $version = phpversion();
  18. $majorProblems[] = <<<EOF
  19. You are running PHP version "<strong>$version</strong>", but Symfony
  20. needs at least PHP "<strong>5.3.2</strong>" to run. Before using Symfony, install
  21. PHP "<strong>5.3.2</strong>" or newer.
  22. EOF;
  23. }
  24. if (!is_writable(__DIR__ . '/../app/cache')) {
  25. $majorProblems[] = 'Change the permissions of the "<strong>app/cache/</strong>"
  26. directory so that the web server can write into it.';
  27. }
  28. if (!is_writable(__DIR__ . '/../app/logs')) {
  29. $majorProblems[] = 'Change the permissions of the "<strong>app/logs/</strong>"
  30. directory so that the web server can write into it.';
  31. }
  32. // extensions
  33. if (!class_exists('DomDocument')) {
  34. $minorProblems[] = 'Install and enable the <strong>php-xml</strong> module.';
  35. }
  36. if (!defined('LIBXML_COMPACT')) {
  37. $minorProblems[] = 'Upgrade your <strong>php-xml</strong> extension with a newer libxml.';
  38. }
  39. if (!((function_exists('apc_store') && ini_get('apc.enabled')) || function_exists('eaccelerator_put') && ini_get('eaccelerator.enable') || function_exists('xcache_set'))) {
  40. $minorProblems[] = 'Install and enable a <strong>PHP accelerator</strong> like APC (highly recommended).';
  41. }
  42. if (!(!(function_exists('apc_store') && ini_get('apc.enabled')) || version_compare(phpversion('apc'), '3.0.17', '>='))) {
  43. $majorProblems[] = 'Upgrade your <strong>APC</strong> extension (3.0.17+)';
  44. }
  45. if (!function_exists('token_get_all')) {
  46. $minorProblems[] = 'Install and enable the <strong>Tokenizer</strong> extension.';
  47. }
  48. if (!function_exists('mb_strlen')) {
  49. $minorProblems[] = 'Install and enable the <strong>mbstring</strong> extension.';
  50. }
  51. if (!function_exists('iconv')) {
  52. $minorProblems[] = 'Install and enable the <strong>iconv</strong> extension.';
  53. }
  54. if (!function_exists('utf8_decode')) {
  55. $minorProblems[] = 'Install and enable the <strong>XML</strong> extension.';
  56. }
  57. if (PHP_OS != 'WINNT' && !function_exists('posix_isatty')) {
  58. $minorProblems[] = 'Install and enable the <strong>php_posix</strong> extension (used to colorize the CLI output).';
  59. }
  60. if (!class_exists('Locale')) {
  61. $minorProblems[] = 'Install and enable the <strong>intl</strong> extension.';
  62. } else {
  63. $version = '';
  64. if (defined('INTL_ICU_VERSION')) {
  65. $version = INTL_ICU_VERSION;
  66. } else {
  67. $reflector = new \ReflectionExtension('intl');
  68. ob_start();
  69. $reflector->info();
  70. $output = strip_tags(ob_get_clean());
  71. preg_match('/^ICU version (.*)$/m', $output, $matches);
  72. $version = $matches[1];
  73. }
  74. if (!version_compare($version, '4.0', '>=')) {
  75. $minorProblems[] = 'Upgrade your <strong>intl</strong> extension with a newer ICU version (4+).';
  76. }
  77. }
  78. if (!class_exists('SQLite3') && !in_array('sqlite', PDO::getAvailableDrivers())) {
  79. $majorProblems[] = 'Install and enable the <strong>SQLite3</strong> or <strong>PDO_SQLite</strong> extension.';
  80. }
  81. if (!function_exists('json_encode')) {
  82. $majorProblems[] = 'Install and enable the <strong>json</strong> extension.';
  83. }
  84. if (!function_exists('session_start')) {
  85. $majorProblems[] = 'Install and enable the <strong>session</strong> extension.';
  86. }
  87. if (!function_exists('ctype_alpha')) {
  88. $majorProblems[] = 'Install and enable the <strong>ctype</strong> extension.';
  89. }
  90. // php.ini
  91. if (!ini_get('date.timezone')) {
  92. $phpini = true;
  93. $majorProblems[] = 'Set the "<strong>date.timezone</strong>" setting in php.ini<a href="#phpini">*</a> (like Europe/Paris).';
  94. }
  95. if (ini_get('short_open_tag')) {
  96. $phpini = true;
  97. $minorProblems[] = 'Set <strong>short_open_tag</strong> to <strong>off</strong> in php.ini<a href="#phpini">*</a>.';
  98. }
  99. if (ini_get('magic_quotes_gpc')) {
  100. $phpini = true;
  101. $minorProblems[] = 'Set <strong>magic_quotes_gpc</strong> to <strong>off</strong> in php.ini<a href="#phpini">*</a>.';
  102. }
  103. if (ini_get('register_globals')) {
  104. $phpini = true;
  105. $minorProblems[] = 'Set <strong>register_globals</strong> to <strong>off</strong> in php.ini<a href="#phpini">*</a>.';
  106. }
  107. if (ini_get('session.auto_start')) {
  108. $phpini = true;
  109. $minorProblems[] = 'Set <strong>session.auto_start</strong> to <strong>off</strong> in php.ini<a href="#phpini">*</a>.';
  110. }
  111. ?>
  112. <!DOCTYPE html>
  113. <html>
  114. <head>
  115. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  116. <link href="bundles/sensiodistribution/webconfigurator/css/install.css" rel="stylesheet" type="text/css" media="all" />
  117. <title>Symfony Configuration</title>
  118. </head>
  119. <body>
  120. <div id="symfony-wrapper">
  121. <div id="symfony-content">
  122. <div class="symfony-blocks-install">
  123. <div class="symfony-block-logo">
  124. <img src="bundles/sensiodistribution/webconfigurator/images/logo-big.gif" alt="sf_symfony" />
  125. </div>
  126. <div class="symfony-block-content">
  127. <h1>Welcome!</h1>
  128. <p>Welcome to your new Symfony project.</p>
  129. <p>This script will guide you through the basic configuration of your project. You can also do the same by editing the ‘<strong>app/config/parameters.ini</strong>’ file directly.</p>
  130. <?php if (count($majorProblems)): ?>
  131. <h2>
  132. <span><?php echo count($majorProblems) ?> Major problems</span>
  133. </h2>
  134. <p>Major problems have been detected and <strong>must</strong> be fixed before continuing :</p>
  135. <ol>
  136. <?php foreach ($majorProblems as $problem): ?>
  137. <li><?php echo $problem; ?></li>
  138. <?php endforeach ?>
  139. </ol>
  140. <?php endif ?>
  141. <?php if (count($minorProblems)): ?>
  142. <h2>Recommendations</h2>
  143. <p>
  144. <?php if ($majorProblems): ?>
  145. Additionally, to
  146. <?php else: ?>
  147. To<?php endif; ?>
  148. enhance your Symfony experience, it’s recommended that you fix the following :
  149. </p>
  150. <ol>
  151. <?php foreach ($minorProblems as $problem): ?>
  152. <li><?php echo $problem; ?></li>
  153. <?php endforeach; ?>
  154. </ol>
  155. <?php endif ?>
  156. <?php if ($phpini): ?>
  157. <a id="phpini"></a>
  158. <p>*
  159. <?php if (get_cfg_var('cfg_file_path')): ?>
  160. Changes to the <strong>php.ini</strong> file must be done in "<strong><?php echo get_cfg_var('cfg_file_path') ?></strong>".
  161. <?php else: ?>
  162. To change settings, create a "<strong>php.ini</strong>".
  163. <?php endif; ?>
  164. </p>
  165. </div>
  166. <?php endif; ?>
  167. <ul class="symfony-install-continue">
  168. <?php if (!count($majorProblems)): ?>
  169. <li><a href="app_dev.php/_configurator/">Configure your Symfony Application online</a></li>
  170. <li><a href="app_dev.php/">Bypass configuration and go to the Welcome page</a></li>
  171. <?php endif ?>
  172. <li><a href="config.php">Re-check configuration</a></li>
  173. </ul>
  174. </div>
  175. </div>
  176. </div>
  177. <div class="version">Symfony Standard Edition</div>
  178. </body>
  179. </html>