artisan.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php namespace Laravel\CLI; defined('APP_PATH') or die('No direct script access.');
  2. use Laravel\IoC;
  3. use Laravel\Bundle;
  4. use Laravel\Database as DB;
  5. /**
  6. * Fire up the default bundle. This will ensure any dependencies that
  7. * need to be registered in the IoC container are registered and that
  8. * the auto-loader mappings are registered.
  9. */
  10. Bundle::start(DEFAULT_BUNDLE);
  11. /**
  12. * We will register all of the Laravel provided tasks inside the IoC
  13. * container so they can be resolved by the task class. This allows
  14. * us to seamlessly add tasks to the CLI so that the Task class
  15. * doesn't have to worry about how to resolve core tasks.
  16. */
  17. /**
  18. * The bundle task is responsible for the installation of bundles
  19. * and their dependencies. It utilizes the bundles API to get the
  20. * meta-data for the available bundles.
  21. */
  22. IoC::register('task: bundle', function()
  23. {
  24. return new Tasks\Bundle\Bundler;
  25. });
  26. /**
  27. * The migrate task is responsible for running database migrations
  28. * as well as migration rollbacks. We will also create an instance
  29. * of the migration resolver and database classes, which are used
  30. * to perform various support functions for the migrator.
  31. */
  32. IoC::register('task: migrate', function()
  33. {
  34. $database = new Tasks\Migrate\Database;
  35. $resolver = new Tasks\Migrate\Resolver($database);
  36. return new Tasks\Migrate\Migrator($resolver, $database);
  37. });
  38. /**
  39. * We will wrap the command execution in a try / catch block and
  40. * simply write out any exception messages we receive to the CLI
  41. * for the developer. Note that this only writes out messages
  42. * for the CLI exceptions. All others will be not be caught
  43. * and will be totally dumped out to the CLI.
  44. */
  45. try
  46. {
  47. Command::run(array_slice($_SERVER['argv'], 1));
  48. }
  49. catch (\Exception $e)
  50. {
  51. echo $e->getMessage();
  52. }
  53. echo PHP_EOL;