When I want to deploying my app to production. I simply run
composer install –no-dev –optimize-autoloader
Which will result an error.
In TelescopeServiceProvider.php line 10: Class ‘LaravelTelescopeTelescopeApplicationServiceProvider’ not found
Script @php artisan package:discover –ansi handling the post-autoload-dump event returned with error code 1
Advertisement
Answer
Remove
AppProvidersTelescopeServiceProvider::class
fromconfig/app.php
because all providers inside config/app.php is automatically loaded. But in your production environment,laravel/telescope
isn’t installed that meansLaravelTelescopeTelescopeApplicationServiceProvider
is undefined andAppProvidersTelescopeServiceProvider
can not extend an undefined class.Register
AppProvidersTelescopeServiceProvider::class
manually insideapp/Providers/AppServiceProviders.php
<?php namespace AppProviders; use IlluminateSupportServiceProvider; use LaravelTelescopeTelescopeApplicationServiceProvider; class AppServiceProvider extends ServiceProvider { /** * Register any application services. * * @return void */ public function register() { if (class_exists(TelescopeApplicationServiceProvider::class)) { $this->app->register(TelescopeServiceProvider::class); } } /** * Bootstrap any application services. * * @return void */ public function boot() { // } }