91b826befe148e9420093fc034522ad714970c30
[mixstore.git] / app / check.php
1 <?php
2
3 require_once dirname(__FILE__).'/SymfonyRequirements.php';
4
5 $symfonyRequirements = new SymfonyRequirements();
6
7 $iniPath = $symfonyRequirements->getPhpIniConfigPath();
8
9 echo "********************************\n";
10 echo "* *\n";
11 echo "* Symfony requirements check *\n";
12 echo "* *\n";
13 echo "********************************\n\n";
14
15 echo $iniPath ? sprintf("* Configuration file used by PHP: %s\n\n", $iniPath) : "* WARNING: No configuration file (php.ini) used by PHP!\n\n";
16
17 echo "** ATTENTION **\n";
18 echo "* The PHP CLI can use a different php.ini file\n";
19 echo "* than the one used with your web server.\n";
20 if ('\\' == DIRECTORY_SEPARATOR) {
21 echo "* (especially on the Windows platform)\n";
22 }
23 echo "* To be on the safe side, please also launch the requirements check\n";
24 echo "* from your web server using the web/config.php script.\n";
25
26 echo_title('Mandatory requirements');
27
28 $checkPassed = true;
29 foreach ($symfonyRequirements->getRequirements() as $req) {
30 /** @var $req Requirement */
31 echo_requirement($req);
32 if (!$req->isFulfilled()) {
33 $checkPassed = false;
34 }
35 }
36
37 echo_title('Optional recommendations');
38
39 foreach ($symfonyRequirements->getRecommendations() as $req) {
40 echo_requirement($req);
41 }
42
43 exit($checkPassed ? 0 : 1);
44
45 /**
46 * Prints a Requirement instance
47 */
48 function echo_requirement(Requirement $requirement)
49 {
50 $result = $requirement->isFulfilled() ? 'OK' : ($requirement->isOptional() ? 'WARNING' : 'ERROR');
51 echo ' ' . str_pad($result, 9);
52 echo $requirement->getTestMessage() . "\n";
53
54 if (!$requirement->isFulfilled()) {
55 echo sprintf(" %s\n\n", $requirement->getHelpText());
56 }
57 }
58
59 function echo_title($title)
60 {
61 echo "\n** $title **\n\n";
62 }