Skip to content
Advertisement

Telescope error when running composer –no-dev

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

  1. Remove AppProvidersTelescopeServiceProvider::class from config/app.php because all providers inside config/app.php is automatically loaded. But in your production environment, laravel/telescope isn’t installed that means LaravelTelescopeTelescopeApplicationServiceProvider is undefined and AppProvidersTelescopeServiceProvider can not extend an undefined class.

  2. Register AppProvidersTelescopeServiceProvider::class manually inside app/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()
    {
        //
    }
}

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement