commands.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. use Michel\Console\CommandParser;
  3. use Michel\Console\CommandRunner;
  4. use Michel\Console\Output;
  5. use Test\Michel\Console\Command\FooCommand;
  6. set_time_limit(0);
  7. if (file_exists(dirname(__DIR__) . '/../../autoload.php')) {
  8. require dirname(__DIR__) . '/../../autoload.php';
  9. } elseif (file_exists(dirname(__DIR__) . '/vendor/autoload.php')) {
  10. require dirname(__DIR__) . '/vendor/autoload.php';
  11. } else {
  12. die(
  13. 'You need to set up the project dependencies using the following commands:' . PHP_EOL .
  14. 'curl -sS https://getcomposer.org/installer | php' . PHP_EOL .
  15. 'php composer.phar install' . PHP_EOL
  16. );
  17. }
  18. // For modern frameworks using containers and bootstrapping (e.g., Kernel or App classes),
  19. // make sure to retrieve the CommandRunner from the container after booting the application.
  20. // Example for Symfony:
  21. //
  22. // $kernel = new Kernel('dev', true);
  23. // $kernel->boot();
  24. // $container = $kernel->getContainer();
  25. // $app = $container->get(CommandRunner::class);
  26. $runner = new CommandRunner([
  27. new FooCommand(),
  28. ]);
  29. $exitCode = $runner->run(new CommandParser(), new Output());
  30. exit($exitCode);