TinkerServiceProvider.php 1.3 KB

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