MitjaZ's avatar

upgrade from 5.2. to 5.3. Router error

I did all the points needed to upgrade laravel.

i get: FatalThrowableError in Router.php line 781: Call to a member function parameters() on null

Problem is that $route parameter in Router function is null.

i tried to debug with simple route:

Route::get('test_route', function () { dd("test"); });

but error persists. What am I missing...?

0 likes
5 replies
MitjaZ's avatar
MitjaZ
OP
Best Answer
Level 5

Just figured it out, in \App\Http\Kernel.php i had empty array of web middleware group

protected $middlewareGroups = [
        'web' => [
            
        ],
        'api' => [
            'throttle:60,1',
            'bindings',
        ],
    ];

after adding:

'web' => [
            \App\Http\Middleware\EncryptCookies::class,
            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
            \Illuminate\Session\Middleware\StartSession::class,
            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
            \App\Http\Middleware\VerifyCsrfToken::class,
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
        ],

error is gone.

cutups's avatar

Had this same exact issue upgrading 5.2 to 5.3, however, I already had this web array populated. Still getting the same error. Anyone else run into the same issue?

matrix's avatar

@cutups Were you able to resolve this issue? I just did the 5.3 upgrade and this listed fix didn't help me either.

HWilliamRS's avatar

Recently I've been in a situation where I had to do an upgrade from L5.2 to L5.3, I have to say part of the documentation need to be retouched, here’s what I have to add:

In the App\Http\Kernel:

protected $middlewareGroups = [
        'web' => [
            /*
            * Others
            */
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
        ],

        'api' => [
            'throttle:60,1',
            'bindings',
        ],
    ];


protected $routeMiddleware = [
        /*
        * Others
        */
        'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
        'can' => \Illuminate\Auth\Middleware\Authorize::class,
    ];

Don't make the mistake to add this class to the $middleware array

Last but not least, as if you have been migrating your app from previous versions of the framework, you may have still one file for storaging you routes, if thats the case, I recommend to applay middleware bindings to all your groups, until you split your routes as Laravel's recent versions:

app\Http\Routes.php

Route::group(['middleware' => ['bindings']] , function() {
    /*
     * Your routes
     */
}

If you don't do that all your routes model binds will break.

1 like

Please or to participate in this conversation.