#!/usr/bin/env php getDefinition(); $output = new ConsoleOutput(); $containerNotFoundMessage = ''; $input = new ArgvInput(); try { $input->bind($definition); } catch (\Symfony\Component\Console\Exception\RuntimeException $exception) { // Ignore validation issues as we did not yet have the commands definition // As we only need the `--container` option, we are good to go until it is passed *before* the first command argument // Symfony parses the `argv` in its direct order and raises an error when more arguments or options are passed // than described by the default definition. } try { $container = (new ContainerResolver($projectRoot))->resolve($input); $app = (new ApplicationProvisioner())($app, $container); } catch (RuntimeException | InvalidArgumentException $exception) { // Usage information provided by the `ContainerResolver` should be passed to the CLI output $containerNotFoundMessage = sprintf('%s', $exception->getMessage()); } // By running the app even if its not provisioned allows symfony/console to report problems // and/or display available options (like `--container`) $exitCode = $app->run(null, $output); if ($containerNotFoundMessage) { $output->writeln($containerNotFoundMessage); $exitCode = 255; } exit($exitCode);