]>
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('yellow', ' WARNING: No configuration file (php.ini) used by PHP!');
21 echo '> Checking Symfony requirements:'.PHP_EOL
.' ';
24 foreach ($symfonyRequirements->getRequirements() as $req) {
25 if ($helpText = get_error_message($req, $lineSize)) {
26 echo_style('red', 'E');
27 $messages['error'][] = $helpText;
29 echo_style('green', '.');
33 $checkPassed = empty($messages['error']);
35 foreach ($symfonyRequirements->getRecommendations() as $req) {
36 if ($helpText = get_error_message($req, $lineSize)) {
37 echo_style('yellow', 'W');
38 $messages['warning'][] = $helpText;
40 echo_style('green', '.');
45 echo_block('success', 'OK', 'Your system is ready to run Symfony projects');
47 echo_block('error', 'ERROR', 'Your system is not ready to run Symfony projects');
49 echo_title('Fix the following mandatory requirements', 'red');
51 foreach ($messages['error'] as $helpText) {
52 echo ' * '.$helpText.PHP_EOL
;
56 if (!empty($messages['warning'])) {
57 echo_title('Optional recommendations to improve your setup', 'yellow');
59 foreach ($messages['warning'] as $helpText) {
60 echo ' * '.$helpText.PHP_EOL
;
65 echo_style('title', 'Note');
66 echo ' The command console could use a different php.ini file'.PHP_EOL
;
67 echo_style('title', '~~~~');
68 echo ' than the one used with your web server. To be on the'.PHP_EOL
;
69 echo ' safe side, please check the requirements from your web'.PHP_EOL
;
70 echo ' server using the ';
71 echo_style('yellow', 'web/config.php');
72 echo ' script.'.PHP_EOL
;
75 exit($checkPassed ? 0 : 1);
77 function get_error_message(Requirement
$requirement, $lineSize)
79 if ($requirement->isFulfilled()) {
83 $errorMessage = wordwrap($requirement->getTestMessage(), $lineSize - 3, PHP_EOL
.' ').PHP_EOL
;
84 $errorMessage .= ' > '.wordwrap($requirement->getHelpText(), $lineSize - 5, PHP_EOL
.' > ').PHP_EOL
;
89 function echo_title($title, $style = null)
91 $style = $style ?: 'title';
94 echo_style($style, $title.PHP_EOL
);
95 echo_style($style, str_repeat('~', strlen($title)).PHP_EOL
);
99 function echo_style($style, $message)
103 'reset' => "\033[0m",
105 'green' => "\033[32m",
106 'yellow' => "\033[33m",
107 'error' => "\033[37;41m",
108 'success' => "\033[37;42m",
109 'title' => "\033[34m",
111 $supports = has_color_support();
113 echo($supports ? $styles[$style] : '').$message.($supports ? $styles['reset'] : '');
116 function echo_block($style, $title, $message)
118 $message = ' '.trim($message).' ';
119 $width = strlen($message);
121 echo PHP_EOL
.PHP_EOL
;
123 echo_style($style, str_repeat(' ', $width));
125 echo_style($style, str_pad(' ['.$title.']', $width, ' ', STR_PAD_RIGHT
));
127 echo_style($style, $message);
129 echo_style($style, str_repeat(' ', $width));
133 function has_color_support()
137 if (null === $support) {
138 if (DIRECTORY_SEPARATOR
== '\\') {
139 $support = false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI');
141 $support = function_exists('posix_isatty') && @posix_isatty(STDOUT
);