Skip to content
Snippets Groups Projects
Select Git revision
  • 0afc0a64393dc36aa9a29a0f21fc44007ceae8d1
  • master default
  • 2023
  • branche-avec-truc-style
  • branche-a-rebase
5 results

README.md

Blame
  • symfony_requirements 3.84 KiB
    #!/usr/bin/env php
    <?php
    
    require_once dirname(__FILE__).'/../var/SymfonyRequirements.php';
    
    $lineSize = 70;
    $symfonyRequirements = new SymfonyRequirements();
    $iniPath = $symfonyRequirements->getPhpIniConfigPath();
    
    echo_title('Symfony Requirements Checker');
    
    echo '> PHP is using the following php.ini file:'.PHP_EOL;
    if ($iniPath) {
        echo_style('green', '  '.$iniPath);
    } else {
        echo_style('yellow', '  WARNING: No configuration file (php.ini) used by PHP!');
    }
    
    echo PHP_EOL.PHP_EOL;
    
    echo '> Checking Symfony requirements:'.PHP_EOL.'  ';
    
    $messages = array();
    foreach ($symfonyRequirements->getRequirements() as $req) {
        if ($helpText = get_error_message($req, $lineSize)) {
            echo_style('red', 'E');
            $messages['error'][] = $helpText;
        } else {
            echo_style('green', '.');
        }
    }
    
    $checkPassed = empty($messages['error']);
    
    foreach ($symfonyRequirements->getRecommendations() as $req) {
        if ($helpText = get_error_message($req, $lineSize)) {
            echo_style('yellow', 'W');
            $messages['warning'][] = $helpText;
        } else {
            echo_style('green', '.');
        }
    }
    
    if ($checkPassed) {
        echo_block('success', 'OK', 'Your system is ready to run Symfony projects');
    } else {
        echo_block('error', 'ERROR', 'Your system is not ready to run Symfony projects');
    
        echo_title('Fix the following mandatory requirements', 'red');
    
        foreach ($messages['error'] as $helpText) {
            echo ' * '.$helpText.PHP_EOL;
        }
    }
    
    if (!empty($messages['warning'])) {
        echo_title('Optional recommendations to improve your setup', 'yellow');
    
        foreach ($messages['warning'] as $helpText) {
            echo ' * '.$helpText.PHP_EOL;
        }
    }
    
    echo PHP_EOL;
    echo_style('title', 'Note');
    echo '  The command console could use a different php.ini file'.PHP_EOL;
    echo_style('title', '~~~~');
    echo '  than the one used with your web server. To be on the'.PHP_EOL;
    echo '      safe side, please check the requirements from your web'.PHP_EOL;
    echo '      server using the ';