]>
git.immae.eu Git - github/wallabag/wallabag.git/blob - bin/symfony_requirements
4 require_once dirname(__FILE__
).'/../var/SymfonyRequirements.php';
7 $symfonyRequirements = new SymfonyRequirements();
8 $iniPath = $symfonyRequirements->getPhpIniConfigPath();
10 echo_title('Symfony Requirements Checker');
12 echo '> PHP is using the following php.ini file:'.PHP_EOL
;
14 echo_style('green', ' '.$iniPath);
16 echo_style('warning', ' WARNING: No configuration file (php.ini) used by PHP!');
21 echo '> Checking Symfony requirements:'.PHP_EOL
.' ';
24 foreach ($symfonyRequirements->getRequirements() as $req) {
25 /** @var $req Requirement */
26 if ($helpText = get_error_message($req, $lineSize)) {
27 echo_style('red', 'E');
28 $messages['error'][] = $helpText;
30 echo_style('green', '.');
34 $checkPassed = empty($messages['error']);
36 foreach ($symfonyRequirements->getRecommendations() as $req) {
37 if ($helpText = get_error_message($req, $lineSize)) {
38 echo_style('yellow', 'W');
39 $messages['warning'][] = $helpText;
41 echo_style('green', '.');
46 echo_block('success', 'OK', 'Your system is ready to run Symfony projects');
48 echo_block('error', 'ERROR', 'Your system is not ready to run Symfony projects');
50 echo_title('Fix the following mandatory requirements', 'red');
52 foreach ($messages['error'] as $helpText) {
53 echo ' * '.$helpText.PHP_EOL
;
57 if (!empty($messages['warning'])) {
58 echo_title('Optional recommendations to improve your setup', 'yellow');
60 foreach ($messages['warning'] as $helpText) {
61 echo ' * '.$helpText.PHP_EOL
;
66 echo_style('title', 'Note');
67 echo ' The command console could use a different php.ini file'.PHP_EOL
;
68 echo_style('title', '~~~~');
69 echo ' than the one used with your web server. To be on the'.PHP_EOL
;
70 echo ' safe side, please check the requirements from your web'.PHP_EOL
;
71 echo ' server using the ';
72 echo_style('yellow', 'web/config.php');
73 echo ' script.'.PHP_EOL
;
76 exit($checkPassed ? 0 : 1);
78 function get_error_message(Requirement
$requirement, $lineSize)
80 if ($requirement->isFulfilled()) {
84 $errorMessage = wordwrap($requirement->getTestMessage(), $lineSize - 3, PHP_EOL
.' ').PHP_EOL
;
85 $errorMessage .= ' > '.wordwrap($requirement->getHelpText(), $lineSize - 5, PHP_EOL
.' > ').PHP_EOL
;
90 function echo_title($title, $style = null)
92 $style = $style ?: 'title';
95 echo_style($style, $title.PHP_EOL
);
96 echo_style($style, str_repeat('~', strlen($title)).PHP_EOL
);
100 function echo_style($style, $message)
104 'reset' => "\033[0m",
106 'green' => "\033[32m",
107 'yellow' => "\033[33m",
108 'error' => "\033[37;41m",
109 'success' => "\033[37;42m",
110 'title' => "\033[34m",
112 $supports = has_color_support();
114 echo($supports ? $styles[$style] : '').$message.($supports ? $styles['reset'] : '');
117 function echo_block($style, $title, $message)
119 $message = ' '.trim($message).' ';
120 $width = strlen($message);
122 echo PHP_EOL
.PHP_EOL
;
124 echo_style($style, str_repeat(' ', $width).PHP_EOL
);
125 echo_style($style, str_pad(' ['.$title.']', $width, ' ', STR_PAD_RIGHT
).PHP_EOL
);
126 echo_style($style, str_pad($message, $width, ' ', STR_PAD_RIGHT
).PHP_EOL
);
127 echo_style($style, str_repeat(' ', $width).PHP_EOL
);
130 function has_color_support()
134 if (null === $support) {
135 if (DIRECTORY_SEPARATOR
== '\\') {
136 $support = false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI');
138 $support = function_exists('posix_isatty') && @posix_isatty(STDOUT
);