artisan.php 1.3 KB

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