Skip to content
Permalink
Browse files

just use web group by default

  • Loading branch information...
taylorotwell committed Mar 23, 2016
1 parent 1d5e88d commit 5c30c98db96459b4cc878d085490e4677b0b67ed
Showing with 19 additions and 8 deletions.
  1. +2 −6 app/Http/routes.php
  2. +17 −2 app/Providers/RouteServiceProvider.php
@@ -11,10 +11,6 @@
|
*/
Route::group(['middleware' => ['web']], function () {
Route::get('/', function () {
return view('welcome');
});
Route::get('/', function () {
return view('welcome');
});
@@ -8,7 +8,7 @@
class RouteServiceProvider extends ServiceProvider
{
/**
* This namespace is applied to the controller routes in your routes file.
* This namespace is applied to your controller routes.
*
* In addition, it is set as the URL generator's root namespace.
*
@@ -37,7 +37,22 @@ public function boot(Router $router)
*/
public function map(Router $router)
{
$router->group(['namespace' => $this->namespace], function ($router) {
$this->mapWebRoutes($router);
//
}
/**
* Define the "web" routes for the application.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
protected function mapWebRoutes(Router $router)
{
$router->group([
'namespace' => $this->namespace, 'middleware' => 'web'
], function ($router) {
require app_path('Http/routes.php');
});
}

11 comments on commit 5c30c98

@vlakoff

This comment has been minimized.

Copy link
Contributor

replied Mar 24, 2016

But then how to avoid adding the web middlewares? (edit: without rewriting the service provider...)

@vlakoff

This comment has been minimized.

Copy link
Contributor

replied Mar 24, 2016

IMHO, silentiy applying a group of middlewares doesn't sound good. Better be explicit.

@jenky

This comment has been minimized.

Copy link

replied Mar 24, 2016

Just remove the middleware in RouteServiceProvider then uses it in routes.php

@vlakoff

This comment has been minimized.

Copy link
Contributor

replied Mar 24, 2016

On second thought, maybe it's not that bad.

@scrubmx

This comment has been minimized.

Copy link
Contributor

replied Mar 24, 2016

@vlakoff I think 99% of the time you are using it anyway. This, to me, feels better and more user-friendly.

@vlakoff

This comment has been minimized.

Copy link
Contributor

replied Mar 24, 2016

I'm just a bit reluctant to changes ;) This way it's more newcomer-friendly while as well editable. Refs #3609.

@huglester

This comment has been minimized.

Copy link

replied Mar 25, 2016

Probably it is more for 'newcommers' oriented, where you put everything in bad route and you have no cookies, nothing

@snapey

This comment has been minimized.

Copy link

replied Mar 29, 2016

The artisan console command make:auth needs amending in line with this change?
framework/src/Illuminate/Auth/Console/stubs/make/routes.stub

@jimgwhit

This comment has been minimized.

Copy link

replied Mar 29, 2016

Please update the docs as well, as there are so many questions on this.

@snapey

This comment has been minimized.

Copy link

replied Mar 29, 2016

@nlanderson

This comment has been minimized.

Copy link

replied Apr 1, 2016

I was confused by this change so to test it I created a new project, 'make:auth-ed up' (so to speak), created a test view, controller, etc, made a string input(required) and var_dump-ed the $errors variable at the bottom of the page for output when I purposely generated an error by leaving the required entry empty.

Results:

WITHOUT the middleware group specified in my routes.php file, I get an Undefined Variable for $errors. If I add the 'web' middleware group to my routes.php file, I am able to access that variable.

Unless I am missing/missed something in my above development - which is ENTIRELY possible, I think saying "just use web group by default" for this change is misleading because that implies that the 'web' group is now called automatically for every request and, since I couldn't access the $errors variable, that doesn't seem to be the case.

If "just use web group by default" only applies to the Authentication functionality, shouldn't that be specified? (ie maintaining newcomer happiness)

Please sign in to comment.
You can’t perform that action at this time.