artisan.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php namespace Laravel\CLI; defined('DS') or die('No direct script access.');
  2. use Laravel\Bundle;
  3. use Laravel\Config;
  4. use Laravel\Request;
  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. * The default database connection may be set by specifying a value
  13. * for the "database" CLI option. This allows migrations to be run
  14. * conveniently for a test or staging database.
  15. */
  16. if ( ! is_null($database = get_cli_option('db')))
  17. {
  18. Config::set('database.default', $database);
  19. }
  20. /**
  21. * We will register all of the Laravel provided tasks inside the IoC
  22. * container so they can be resolved by the task class. This allows
  23. * us to seamlessly add tasks to the CLI so that the Task class
  24. * doesn't have to worry about how to resolve core tasks.
  25. */
  26. require path('sys').'cli/dependencies'.EXT;
  27. /**
  28. * We will wrap the command execution in a try / catch block and
  29. * simply write out any exception messages we receive to the CLI
  30. * for the developer. Note that this only writes out messages
  31. * for the CLI exceptions. All others will be not be caught
  32. * and will be totally dumped out to the CLI.
  33. */
  34. try
  35. {
  36. Command::run(array_slice($arguments, 1));
  37. }
  38. catch (\Exception $e)
  39. {
  40. echo $e->getMessage();
  41. }
  42. echo PHP_EOL;