aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/check.php
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2016-01-14 18:15:07 +0100
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-01-15 09:35:39 +0100
commit73cd160bfc6e4a1b88f2117eb0c097a91ac5c753 (patch)
treec5ccc9fa57f243126538ae8d9a2f8c459c08bd8c /app/check.php
parent1d405d0e62a708928bccd2222ebd89d4804231f9 (diff)
downloadwallabag-73cd160bfc6e4a1b88f2117eb0c097a91ac5c753.tar.gz
wallabag-73cd160bfc6e4a1b88f2117eb0c097a91ac5c753.tar.zst
wallabag-73cd160bfc6e4a1b88f2117eb0c097a91ac5c753.zip
Switch to Symfony 3 structure
Diffstat (limited to 'app/check.php')
-rw-r--r--app/check.php142
1 files changed, 0 insertions, 142 deletions
diff --git a/app/check.php b/app/check.php
deleted file mode 100644
index 282507f7..00000000
--- a/app/check.php
+++ /dev/null
@@ -1,142 +0,0 @@
1<?php
2
3require_once dirname(__FILE__).'/SymfonyRequirements.php';
4
5$lineSize = 70;
6$symfonyRequirements = new SymfonyRequirements();
7$iniPath = $symfonyRequirements->getPhpIniConfigPath();
8
9echo_title('Symfony2 Requirements Checker');
10
11echo '> PHP is using the following php.ini file:'.PHP_EOL;
12if ($iniPath) {
13 echo_style('green', ' '.$iniPath);
14} else {
15 echo_style('warning', ' WARNING: No configuration file (php.ini) used by PHP!');
16}
17
18echo PHP_EOL.PHP_EOL;
19
20echo '> Checking Symfony requirements:'.PHP_EOL.' ';
21
22$messages = array();
23foreach ($symfonyRequirements->getRequirements() as $req) {
24 /** @var $req Requirement */
25 if ($helpText = get_error_message($req, $lineSize)) {
26 echo_style('red', 'E');
27 $messages['error'][] = $helpText;
28 } else {
29 echo_style('green', '.');
30 }
31}
32
33$checkPassed = empty($messages['error']);
34
35foreach ($symfonyRequirements->getRecommendations() as $req) {
36 if ($helpText = get_error_message($req, $lineSize)) {
37 echo_style('yellow', 'W');
38 $messages['warning'][] = $helpText;
39 } else {
40 echo_style('green', '.');
41 }
42}
43
44if ($checkPassed) {
45 echo_block('success', 'OK', 'Your system is ready to run Symfony2 projects');
46} else {
47 echo_block('error', 'ERROR', 'Your system is not ready to run Symfony2 projects');
48
49 echo_title('Fix the following mandatory requirements', 'red');
50
51 foreach ($messages['error'] as $helpText) {
52 echo ' * '.$helpText.PHP_EOL;
53 }
54}
55
56if (!empty($messages['warning'])) {
57 echo_title('Optional recommendations to improve your setup', 'yellow');
58
59 foreach ($messages['warning'] as $helpText) {
60 echo ' * '.$helpText.PHP_EOL;
61 }
62}
63
64echo PHP_EOL;
65echo_style('title', 'Note');
66echo ' The command console could use a different php.ini file'.PHP_EOL;
67echo_style('title', '~~~~');
68echo ' than the one used with your web server. To be on the'.PHP_EOL;
69echo ' safe side, please check the requirements from your web'.PHP_EOL;
70echo ' server using the ';
71echo_style('yellow', 'web/config.php');
72echo ' script.'.PHP_EOL;
73echo PHP_EOL;
74
75exit($checkPassed ? 0 : 1);
76
77function get_error_message(Requirement $requirement, $lineSize)
78{
79 if ($requirement->isFulfilled()) {
80 return;
81 }
82
83 $errorMessage = wordwrap($requirement->getTestMessage(), $lineSize - 3, PHP_EOL.' ').PHP_EOL;
84 $errorMessage .= ' > '.wordwrap($requirement->getHelpText(), $lineSize - 5, PHP_EOL.' > ').PHP_EOL;
85
86 return $errorMessage;
87}
88
89function echo_title($title, $style = null)
90{
91 $style = $style ?: 'title';
92
93 echo PHP_EOL;
94 echo_style($style, $title.PHP_EOL);
95 echo_style($style, str_repeat('~', strlen($title)).PHP_EOL);
96 echo PHP_EOL;
97}
98
99function echo_style($style, $message)
100{
101 // ANSI color codes
102 $styles = array(
103 'reset' => "\033[0m",
104 'red' => "\033[31m",
105 'green' => "\033[32m",
106 'yellow' => "\033[33m",
107 'error' => "\033[37;41m",
108 'success' => "\033[37;42m",
109 'title' => "\033[34m",
110 );
111 $supports = has_color_support();
112
113 echo($supports ? $styles[$style] : '').$message.($supports ? $styles['reset'] : '');
114}
115
116function echo_block($style, $title, $message)
117{
118 $message = ' '.trim($message).' ';
119 $width = strlen($message);
120
121 echo PHP_EOL.PHP_EOL;
122
123 echo_style($style, str_repeat(' ', $width).PHP_EOL);
124 echo_style($style, str_pad(' ['.$title.']', $width, ' ', STR_PAD_RIGHT).PHP_EOL);
125 echo_style($style, str_pad($message, $width, ' ', STR_PAD_RIGHT).PHP_EOL);
126 echo_style($style, str_repeat(' ', $width).PHP_EOL);
127}
128
129function has_color_support()
130{
131 static $support;
132
133 if (null === $support) {
134 if (DIRECTORY_SEPARATOR == '\\') {
135 $support = false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI');
136 } else {
137 $support = function_exists('posix_isatty') && @posix_isatty(STDOUT);
138 }
139 }
140
141 return $support;
142}