AppServiceProvider.php 566 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace App\Providers;
  3. use Illuminate\Support\ServiceProvider;
  4. class AppServiceProvider extends ServiceProvider
  5. {
  6. /**
  7. * Register any application services.
  8. */
  9. public function register(): void
  10. {
  11. //添加自定义辅助函数
  12. require_once __DIR__ . '/../Helpers/helpers.php';
  13. $this->app->singleton(MenuService::class, function ($app) {
  14. return new MenuService();
  15. });
  16. }
  17. /**
  18. * Bootstrap any application services.
  19. */
  20. public function boot(): void
  21. {
  22. //
  23. }
  24. }