If you’ve finally made the upgrade to Laravel 5.4, you may have been greeted with an ambiguous error message like this one:
If you’ve hit this error, odds are you are registering middleware in a service provider or in your application at runtime. Perhaps something like this:
The underlying issue is that the Laravel router class no longer has the middleware
method, instead favoring the naming aliasMiddleware
. Simply change the method name and you’re good to go.
1 2 3 4 5 | // In with the new $router->aliasMiddleware('admin', 'MyPackage\Http\Middleware\Admin'); // Out with the old $router->middleware('admin', 'MyPackage\Http\Middleware\Admin'); |
// In with the new $router->aliasMiddleware('admin', 'MyPackage\Http\Middleware\Admin'); // Out with the old $router->middleware('admin', 'MyPackage\Http\Middleware\Admin');