Updated to 5.3, the 'web' route group isn't picking up middleware.
I just ran a Laravel Shift to go from 5.2 to 5.3. I'm having some problems with the routing. It seems like the 'web' group is not being applied to my routes in routes/web.php. To make it work I have to add the middleware classes to the middleware array. Furthermore if I include the SubstitueBindings class nothing work. I get a trying to get property of non-object error. If I comment out that class things seem to work fine.
Here is the code from my Http/Kernel.php
class Kernel extends HttpKernel
{
/**
* The application's global HTTP middleware stack.
*
* @var array
*/
protected $middleware = [
CheckForMaintenanceMode::class,
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
StartSession::class,
ShareErrorsFromSession::class,
VerifyCsrfToken::class,
//SubstituteBindings::class,
];
/**
* The application's route middleware groups.
*
* @var array
*/
protected $middlewareGroups = [
'web' => [
// EncryptCookies::class,
// AddQueuedCookiesToResponse::class,
// StartSession::class,
// ShareErrorsFromSession::class,
// VerifyCsrfToken::class,
// SubstituteBindings::class,
],
'api' => [
'throttle:60,1',
'bindings',
],
];
All of my routes are in /routes/web.php
Here is a copy of my RouteServiceProvider.
<?php
namespace Quickernotes\Providers;
use Illuminate\Support\Facades\Route;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
class RouteServiceProvider extends ServiceProvider
{
/**
* This namespace is applied to your controller routes.
*
* In addition, it is set as the URL generator's root namespace.
*
* @var string
*/
protected $namespace = 'Quickernotes\Http\Controllers';
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
//
parent::boot();
}
/**
* Define the routes for the application.
*
* @return void
*/
public function map()
{
$this->mapApiRoutes();
$this->mapWebRoutes();
//
}
/**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*
* @return void
*/
protected function mapWebRoutes()
{
Route::group([
'middleware' => 'web',
'namespace' => $this->namespace,
], function ($router) {
require base_path('routes/web.php');
});
}
/**
* Define the "api" routes for the application.
*
* These routes are typically stateless.
*
* @return void
*/
protected function mapApiRoutes()
{
Route::group([
'middleware' => 'api',
'namespace' => $this->namespace,
'prefix' => 'api',
], function ($router) {
require base_path('routes/api.php');
});
}
}
The code that is commented out is just me trying to troubleshoot. The app only works if the middleware is applied to the $middleware array and is not touched from the $middlewareGroups array.
Please or to participate in this conversation.