暫無描述

TinkerServiceProvider.php 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace Laravel\Tinker;
  3. use Illuminate\Support\ServiceProvider;
  4. use Laravel\Tinker\Console\TinkerCommand;
  5. use Laravel\Lumen\Application as LumenApplication;
  6. use Illuminate\Foundation\Application as LaravelApplication;
  7. class TinkerServiceProvider extends ServiceProvider
  8. {
  9. /**
  10. * Indicates if loading of the provider is deferred.
  11. *
  12. * @var bool
  13. */
  14. protected $defer = true;
  15. /**
  16. * Boot the service provider.
  17. *
  18. * @return void
  19. */
  20. public function boot()
  21. {
  22. $source = realpath($raw = __DIR__.'/../config/tinker.php') ?: $raw;
  23. if ($this->app instanceof LaravelApplication && $this->app->runningInConsole()) {
  24. $this->publishes([$source => config_path('tinker.php')]);
  25. } elseif ($this->app instanceof LumenApplication) {
  26. $this->app->configure('tinker');
  27. }
  28. $this->mergeConfigFrom($source, 'tinker');
  29. }
  30. /**
  31. * Register the service provider.
  32. *
  33. * @return void
  34. */
  35. public function register()
  36. {
  37. $this->app->singleton('command.tinker', function () {
  38. return new TinkerCommand;
  39. });
  40. $this->commands(['command.tinker']);
  41. }
  42. /**
  43. * Get the services provided by the provider.
  44. *
  45. * @return array
  46. */
  47. public function provides()
  48. {
  49. return ['command.tinker'];
  50. }
  51. }