bailout example



$autoload = __DIR__.'/../../vendor/autoload.php';

if (!file_exists($autoload)) {
    bailout('You should run "composer install" in the component before running this script.');
}

require_once $autoload;

function centered(string $text)
{
    $padding = (int) ((LINE_WIDTH - strlen($text)) / 2);

    return str_repeat(' ', $padding).$text;
}

function cd(string $dir): void
{
    if (false === chdir($dir)) {
        bailout("Could not switch to directory $dir.");
    }
}

function run(string $command): void
{
    exec($command$output$status);

    if (0 !== $status) {
        $output = implode("\n", $output);
        echo "Error while running:\n ".getcwd().'$ '.$command."\nOutput:\n".LINE."$output\n".LINE;

        
if ('cli' !== \PHP_SAPI) {
    throw new Exception('This script must be run from the command line.');
}

require_once __DIR__.'/common.php';
require_once __DIR__.'/autoload.php';

$argc = $_SERVER['argc'];
$argv = $_SERVER['argv'];

if ($argc > 3 || 2 === $argc && '-h' === $argv[1]) {
    bailout(<<<'MESSAGE' Usage: php update-data.php <path/to/icu/source> <path/to/icu/build> Updates the ICU data for Symfony to the latest version of ICU. If you downloaded the git repository before, you can pass the path to the repository source in the first optional argument. If you also built the repository before, you can pass the directory where that build is stored in the second parameter. The build directory needs to contain the subdirectories bin/ and lib/. For running this script, the intl extension must be loaded and all vendors must have been installed through composer: composer install
Home | Imprint | This part of the site doesn't use cookies.