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\\
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
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.
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
],
];
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
];
In my case it was solved by running
php artisan optimize:clear
php artisan config:cache
The optimize:clear
commands clears everything
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.
}