Laravel 6.0 php artisan route:list returns “Target class [App\Http\Controllers\SessionsController] does not exist.”

后端 未结 17 1812
無奈伤痛
無奈伤痛 2021-02-05 10:36

I am using Laravel 6.0 and I try to list all my routes with artisan route:list, but it fails and returns:

Illuminate\\Contracts\\Container\\

相关标签:
17条回答
  • 2021-02-05 11:10

    In my case it was a matter of Linux's file name case sensitivity. For a file named IndexController, having Indexcontroller will work in windows but not in Linux

    0 讨论(0)
  • 2021-02-05 11:12

    I did all these

    1: php artisan config:cache

    2: checked for controller name spellings.

    3: composer dump-autoload

    4: Just changed the forward / slash to backward \ in route.

    4th one worked for me.

    0 讨论(0)
  • 2021-02-05 11:12

    I had this problem while leaving an empty middleware class in my middleware groups by mistake :

        /**
         * The application's route middleware groups.
         *
         * @var array
         */
        protected $middlewareGroups = [
            'web' => [
                Middleware\EncryptCookies::class,
                \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
                \Illuminate\Session\Middleware\StartSession::class,
                \Illuminate\View\Middleware\ShareErrorsFromSession::class,
                Middleware\VerifyCsrfToken::class,
                \Illuminate\Routing\Middleware\SubstituteBindings::class,
            ],
    
            'api' => [
                'throttle:100,1',
                'bindings',
                'localization',
                '' // Was empty by mistake
            ],
        ];
    
    0 讨论(0)
  • 2021-02-05 11:12

    I had the same problem but with a middleware controller. So finally I linked that middleware in kerner.php file. It is located at app\Http\Kernel.php

    I have added this line in route middleware.
    'authpostmanweb' => \App\Http\Middleware\AuthPostmanWeb::class

      protected $routeMiddleware = [
            'auth' => \App\Http\Middleware\Authenticate::class,
            'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
            'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
            'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
            'can' => \Illuminate\Auth\Middleware\Authorize::class,
            'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
            'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
            'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
            'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
            'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
            'authpostmanweb' => \App\Http\Middleware\AuthPostmanWeb::class
        ];
    
    0 讨论(0)
  • 2021-02-05 11:16

    In my case it was solved by running

    php artisan optimize:clear
    php artisan config:cache
    

    The optimize:clearcommands clears everything

    0 讨论(0)
  • 2021-02-05 11:17

    try to correct your controller name

    my route was

    Route::get('/lien/{id}','liensControler@show');
    

    and my controller was

    class liensController extends Controller
    {
      // all the methods of controller goes here.
    }
    
    0 讨论(0)
提交回复
热议问题