SailServiceProvider.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace Laravel\Sail;
  3. use Illuminate\Contracts\Support\DeferrableProvider;
  4. use Illuminate\Support\ServiceProvider;
  5. use Laravel\Sail\Console\AddCommand;
  6. use Laravel\Sail\Console\InstallCommand;
  7. use Laravel\Sail\Console\PublishCommand;
  8. class SailServiceProvider extends ServiceProvider implements DeferrableProvider
  9. {
  10. /**
  11. * Bootstrap any application services.
  12. *
  13. * @return void
  14. */
  15. public function boot()
  16. {
  17. $this->registerCommands();
  18. $this->configurePublishing();
  19. }
  20. /**
  21. * Register the console commands for the package.
  22. *
  23. * @return void
  24. */
  25. protected function registerCommands()
  26. {
  27. if ($this->app->runningInConsole()) {
  28. $this->commands([
  29. InstallCommand::class,
  30. AddCommand::class,
  31. PublishCommand::class,
  32. ]);
  33. }
  34. }
  35. /**
  36. * Configure publishing for the package.
  37. *
  38. * @return void
  39. */
  40. protected function configurePublishing()
  41. {
  42. if ($this->app->runningInConsole()) {
  43. $this->publishes([
  44. __DIR__ . '/../runtimes' => $this->app->basePath('docker'),
  45. ], ['sail', 'sail-docker']);
  46. $this->publishes([
  47. __DIR__ . '/../bin/sail' => $this->app->basePath('sail'),
  48. ], ['sail', 'sail-bin']);
  49. $this->publishes([
  50. __DIR__ . '/../database' => $this->app->basePath('docker'),
  51. ], ['sail', 'sail-database']);
  52. }
  53. }
  54. /**
  55. * Get the services provided by the provider.
  56. *
  57. * @return array
  58. */
  59. public function provides()
  60. {
  61. return [
  62. InstallCommand::class,
  63. PublishCommand::class,
  64. ];
  65. }
  66. }