requirements.php 4.04 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
<?php
/**
 * Application requirement checker script.
 *
 * In order to run this script use the following console command:
 * php requirements.php
 *
 * In order to run this script from the web, you should copy it to the web root.
 * If you are using Linux you can create a hard link instead, using the following command:
 * ln requirements.php ../requirements.php
 */

// you may need to adjust this path to the correct Yii framework path
14
$frameworkPath = dirname(__FILE__) . '/vendor/yiisoft/yii2';
15 16 17 18

if (!is_dir($frameworkPath)) {
	echo '<h1>Error</h1>';
	echo '<p><strong>The path to yii framework seems to be incorrect.</strong></p>';
Luciano Baraglia committed
19
	echo '<p>You need to install Yii framework via composer or adjust the framework path in file <abbr title="' . __FILE__ . '">' . basename(__FILE__) . '</abbr>.</p>';
20 21
	echo '<p>Please refer to the <abbr title="' . dirname(__FILE__) . '/README.md">README</abbr> on how to install Yii.</p>';
}
22 23 24 25 26 27 28

require_once($frameworkPath . '/requirements/YiiRequirementChecker.php');
$requirementsChecker = new YiiRequirementChecker();

/**
 * Adjust requirements according to your application specifics.
 */
29
$requirements = array(
30
	// Database :
31
	array(
32 33 34 35
		'name' => 'PDO extension',
		'mandatory' => true,
		'condition' => extension_loaded('pdo'),
		'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>',
36 37
	),
	array(
38 39 40 41 42
		'name' => 'PDO SQLite extension',
		'mandatory' => false,
		'condition' => extension_loaded('pdo_sqlite'),
		'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>',
		'memo' => 'Required for SQLite database.',
43 44
	),
	array(
45 46 47 48 49
		'name' => 'PDO MySQL extension',
		'mandatory' => false,
		'condition' => extension_loaded('pdo_mysql'),
		'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>',
		'memo' => 'Required for MySQL database.',
50 51
	),
	array(
gitrad committed
52 53 54 55 56
		'name' => 'PDO PostgreSQL extension',
		'mandatory' => false,
		'condition' => extension_loaded('pdo_pgsql'),
		'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>',
		'memo' => 'Required for PostgreSQL database.',
57
	),
58
	// Cache :
59
	array(
60 61 62 63 64
		'name' => 'Memcache extension',
		'mandatory' => false,
		'condition' => extension_loaded('memcache') || extension_loaded('memcached'),
		'by' => '<a href="http://www.yiiframework.com/doc/api/CMemCache">CMemCache</a>',
		'memo' => extension_loaded('memcached') ? 'To use memcached set <a href="http://www.yiiframework.com/doc/api/CMemCache#useMemcached-detail">CMemCache::useMemcached</a> to <code>true</code>.' : ''
65 66
	),
	array(
67 68
		'name' => 'APC extension',
		'mandatory' => false,
marsuboss committed
69
		'condition' => extension_loaded('apc'),
70
		'by' => '<a href="http://www.yiiframework.com/doc/api/CApcCache">CApcCache</a>',
71
	),
72
	// Additional PHP extensions :
73
	array(
74 75 76 77 78
		'name' => 'Mcrypt extension',
		'mandatory' => false,
		'condition' => extension_loaded('mcrypt'),
		'by' => '<a href="http://www.yiiframework.com/doc/api/CSecurityManager">CSecurityManager</a>',
		'memo' => 'Required by encrypt and decrypt methods.'
79
	),
80
	// PHP ini :
81
	'phpSafeMode' => array(
82 83 84 85 86
		'name' => 'PHP safe mode',
		'mandatory' => false,
		'condition' => $requirementsChecker->checkPhpIniOff("safe_mode"),
		'by' => 'File uploading and console command execution',
		'memo' => '"safe_mode" should be disabled at php.ini',
87 88
	),
	'phpExposePhp' => array(
89 90 91 92 93
		'name' => 'Expose PHP',
		'mandatory' => false,
		'condition' => $requirementsChecker->checkPhpIniOff("expose_php"),
		'by' => 'Security reasons',
		'memo' => '"expose_php" should be disabled at php.ini',
94 95
	),
	'phpAllowUrlInclude' => array(
96 97 98 99 100
		'name' => 'PHP allow url include',
		'mandatory' => false,
		'condition' => $requirementsChecker->checkPhpIniOff("allow_url_include"),
		'by' => 'Security reasons',
		'memo' => '"allow_url_include" should be disabled at php.ini',
101 102
	),
	'phpSmtp' => array(
103 104 105 106 107
		'name' => 'PHP mail SMTP',
		'mandatory' => false,
		'condition' => strlen(ini_get('SMTP'))>0,
		'by' => 'Email sending',
		'memo' => 'PHP mail SMTP server required',
108 109
	),
);
110
$requirementsChecker->checkYii()->check($requirements)->render();