requirements.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. // you may need to adjust this path to the correct Yii framework path
  13. $frameworkPath = dirname(__FILE__) . '/vendor/yiisoft/yii2';
  14. if (!is_dir($frameworkPath)) {
  15. echo '<h1>Error</h1>';
  16. echo '<p><strong>The path to yii framework seems to be incorrect.</strong></p>';
  17. echo '<p>You need to install Yii framework via composer or adjust the framework path in file <abbr title="' . __FILE__ . '">' . basename(__FILE__) . '</abbr>.</p>';
  18. echo '<p>Please refer to the <abbr title="' . dirname(__FILE__) . '/README.md">README</abbr> on how to install Yii.</p>';
  19. }
  20. require_once($frameworkPath . '/requirements/YiiRequirementChecker.php');
  21. $requirementsChecker = new YiiRequirementChecker();
  22. /**
  23. * Adjust requirements according to your application specifics.
  24. */
  25. $requirements = array(
  26. // Database :
  27. array(
  28. 'name' => 'PDO extension',
  29. 'mandatory' => true,
  30. 'condition' => extension_loaded('pdo'),
  31. 'by' => 'All DB-related classes',
  32. ),
  33. array(
  34. 'name' => 'PDO SQLite extension',
  35. 'mandatory' => false,
  36. 'condition' => extension_loaded('pdo_sqlite'),
  37. 'by' => 'All DB-related classes',
  38. 'memo' => 'Required for SQLite database.',
  39. ),
  40. array(
  41. 'name' => 'PDO MySQL extension',
  42. 'mandatory' => false,
  43. 'condition' => extension_loaded('pdo_mysql'),
  44. 'by' => 'All DB-related classes',
  45. 'memo' => 'Required for MySQL database.',
  46. ),
  47. array(
  48. 'name' => 'PDO PostgreSQL extension',
  49. 'mandatory' => false,
  50. 'condition' => extension_loaded('pdo_pgsql'),
  51. 'by' => 'All DB-related classes',
  52. 'memo' => 'Required for PostgreSQL database.',
  53. ),
  54. // Cache :
  55. array(
  56. 'name' => 'Memcache extension',
  57. 'mandatory' => false,
  58. 'condition' => extension_loaded('memcache') || extension_loaded('memcached'),
  59. 'by' => '<a href="http://www.yiiframework.com/doc-2.0/yii-caching-memcache.html">MemCache</a>',
  60. '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>.' : ''
  61. ),
  62. array(
  63. 'name' => 'APC extension',
  64. 'mandatory' => false,
  65. 'condition' => extension_loaded('apc'),
  66. 'by' => '<a href="http://www.yiiframework.com/doc-2.0/yii-caching-apccache.html">ApcCache</a>',
  67. ),
  68. // PHP ini :
  69. 'phpSafeMode' => array(
  70. 'name' => 'PHP safe mode',
  71. 'mandatory' => false,
  72. 'condition' => $requirementsChecker->checkPhpIniOff("safe_mode"),
  73. 'by' => 'File uploading and console command execution',
  74. 'memo' => '"safe_mode" should be disabled at php.ini',
  75. ),
  76. 'phpExposePhp' => array(
  77. 'name' => 'Expose PHP',
  78. 'mandatory' => false,
  79. 'condition' => $requirementsChecker->checkPhpIniOff("expose_php"),
  80. 'by' => 'Security reasons',
  81. 'memo' => '"expose_php" should be disabled at php.ini',
  82. ),
  83. 'phpAllowUrlInclude' => array(
  84. 'name' => 'PHP allow url include',
  85. 'mandatory' => false,
  86. 'condition' => $requirementsChecker->checkPhpIniOff("allow_url_include"),
  87. 'by' => 'Security reasons',
  88. 'memo' => '"allow_url_include" should be disabled at php.ini',
  89. ),
  90. 'phpSmtp' => array(
  91. 'name' => 'PHP mail SMTP',
  92. 'mandatory' => false,
  93. 'condition' => strlen(ini_get('SMTP'))>0,
  94. 'by' => 'Email sending',
  95. 'memo' => 'PHP mail SMTP server required',
  96. ),
  97. );
  98. $requirementsChecker->checkYii()->check($requirements)->render();