PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, March 2, 2022

[FIXED] Telescope error when running composer --no-dev

 March 02, 2022     composer-php, laravel, laravel-artisan, php     No comments   

Issue

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 'Laravel\Telescope\TelescopeApplicationServiceProvider' not found

Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1


Solution

  1. Remove App\Providers\TelescopeServiceProvider::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 Laravel\Telescope\TelescopeApplicationServiceProvider is undefined and App\Providers\TelescopeServiceProvider can not extend an undefined class.

  2. Register App\Providers\TelescopeServiceProvider::class manually inside app/Providers/AppServiceProviders.php

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Laravel\Telescope\TelescopeApplicationServiceProvider;

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()
    {
        //
    }
}



Answered By - Quynh Xuan Nguyen
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing