У меня проблема с [Route::group(['middleware' => ['web']], function () {}); ]
[Route::group(['middleware' => ['web']], function () {}); ]
когда я использую его в файле маршрутов, он показывает эту ошибку:
FatalErrorException in Container.php line 702: Maximum function nesting level of '100' reached, aborting!
my routes.php:
use App\Discussion; Route::group(['middleware' => ['web']], function () { Route::get('/', function () { return view('welcome'); }); Route::auth(); }); Route::get('home', function () { $discussion = Discussion::orderBy('created_at', 'asc')->get(); return view('home', [ 'discussions' => $discussion, ]); });
и это homeController:
<?php namespace App\Http\Controllers; use App\Discussion; use App\Http\Requests; use App\User; use Illuminate\Http\Request; class HomeController extends Controller { /** * Create a new controller instance. * * @return void */ public function __construct() { $this->middleware('auth'); } /** * Show the application dashboard. * * @return \Illuminate\Http\Response */ public function index() { } }
это ошибка:
FatalErrorException in Container.php line 702: Maximum function nesting level of '100' reached, aborting! in Container.php line 702 at FatalErrorException->__construct() in HandleExceptions.php line 133 at HandleExceptions->fatalExceptionFromError() in HandleExceptions.php line 118 at HandleExceptions->handleShutdown() in HandleExceptions.php line 0 at Container->normalize() in Container.php line 179 at Container->bind() in Container.php line 1199 at Container->offsetSet() in Container.php line 39 at AuthServiceProvider->Illuminate\Auth\{closure}() in Container.php line 735 at Container->build() in Container.php line 633 at Container->make() in Application.php line 697 at Application->make() in Container.php line 1178 at Container->offsetGet() in Facade.php line 151 at Facade::resolveFacadeInstance() in Facade.php line 120 at Facade::getFacadeRoot() in Facade.php line 207 at Facade::__callStatic() in f6edb10b0490bd0fe5a2fb364a623ddb1e0231d4.php line 56 at Auth::guest() in f6edb10b0490bd0fe5a2fb364a623ddb1e0231d4.php line 56 in PhpEngine.php line 42 at PhpEngine->evaluatePath() in CompilerEngine.php line 59 at CompilerEngine->get() in View.php line 149 at View->getContents() in View.php line 120 at View->renderContents() in View.php line 85 at View->render() in aa3aed20f72e2364ebd8d243052a41cdb52d5295.php line 17 in PhpEngine.php line 42 at PhpEngine->evaluatePath() in CompilerEngine.php line 59 at CompilerEngine->get() in View.php line 149 at View->getContents() in View.php line 120 at View->renderContents() in View.php line 85 at View->render() in Response.php line 53 at Response->setContent() in Response.php line 199 at Response->__construct() in Router.php line 1087 at Router->prepareResponse() in Router.php line 725 at Router->Illuminate\Routing\{closure}() in Pipeline.php line 52 at call_user_func:{C:\wamp\www\social\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:52}() in Pipeline.php line 52 at Pipeline->Illuminate\Routing\{closure}() in VerifyCsrfToken.php line 64 at VerifyCsrfToken->handle() in Pipeline.php line 136 at call_user_func_array:{C:\wamp\www\social\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:136}() in Pipeline.php line 136 at Pipeline->Illuminate\Pipeline\{closure}() in Pipeline.php line 32 at call_user_func:{C:\wamp\www\social\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:32}() in Pipeline.php line 32 at Pipeline->Illuminate\Routing\{closure}() in ShareErrorsFromSession.php line 49 at ShareErrorsFromSession->handle() in Pipeline.php line 136 at call_user_func_array:{C:\wamp\www\social\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:136}() in Pipeline.php line 136 at Pipeline->Illuminate\Pipeline\{closure}() in Pipeline.php line 32 at call_user_func:{C:\wamp\www\social\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:32}() in Pipeline.php line 32 at Pipeline->Illuminate\Routing\{closure}() in StartSession.php line 62 at StartSession->handle() in Pipeline.php line 136 at call_user_func_array:{C:\wamp\www\social\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:136}() in Pipeline.php line 136 at Pipeline->Illuminate\Pipeline\{closure}() in Pipeline.php line 32 at call_user_func:{C:\wamp\www\social\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:32}() in Pipeline.php line 32 at Pipeline->Illuminate\Routing\{closure}() in AddQueuedCookiesToResponse.php line 37 at AddQueuedCookiesToResponse->handle() in Pipeline.php line 136 at call_user_func_array:{C:\wamp\www\social\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:136}() in Pipeline.php line 136 at Pipeline->Illuminate\Pipeline\{closure}() in Pipeline.php line 32 at call_user_func:{C:\wamp\www\social\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:32}() in Pipeline.php line 32 at Pipeline->Illuminate\Routing\{closure}() in EncryptCookies.php line 59 at EncryptCookies->handle() in Pipeline.php line 136 at call_user_func_array:{C:\wamp\www\social\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:136}() in Pipeline.php line 136 at Pipeline->Illuminate\Pipeline\{closure}() in Pipeline.php line 32 at call_user_func:{C:\wamp\www\social\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:32}() in Pipeline.php line 32 at Pipeline->Illuminate\Routing\{closure}() in VerifyCsrfToken.php line 64 at VerifyCsrfToken->handle() in Pipeline.php line 136 at call_user_func_array:{C:\wamp\www\social\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:136}() in Pipeline.php line 136 at Pipeline->Illuminate\Pipeline\{closure}() in Pipeline.php line 32 at call_user_func:{C:\wamp\www\social\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:32}() in Pipeline.php line 32 at Pipeline->Illuminate\Routing\{closure}() in ShareErrorsFromSession.php line 49 at ShareErrorsFromSession->handle() in Pipeline.php line 136 at call_user_func_array:{C:\wamp\www\social\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:136}() in Pipeline.php line 136 at Pipeline->Illuminate\Pipeline\{closure}() in Pipeline.php line 32 at call_user_func:{C:\wamp\www\social\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:32}() in Pipeline.php line 32 at Pipeline->Illuminate\Routing\{closure}() in StartSession.php line 62 at StartSession->handle() in Pipeline.php line 136 at call_user_func_array:{C:\wamp\www\social\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:136}() in Pipeline.php line 136 at Pipeline->Illuminate\Pipeline\{closure}() in Pipeline.php line 32 at call_user_func:{C:\wamp\www\social\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:32}() in Pipeline.php line 32 at Pipeline->Illuminate\Routing\{closure}() in AddQueuedCookiesToResponse.php line 37 at AddQueuedCookiesToResponse->handle() in Pipeline.php line 136 at call_user_func_array:{C:\wamp\www\social\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:136}() in Pipeline.php line 136 at Pipeline->Illuminate\Pipeline\{closure}() in Pipeline.php line 32 at call_user_func:{C:\wamp\www\social\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:32}() in Pipeline.php line 32 at Pipeline->Illuminate\Routing\{closure}() in EncryptCookies.php line 59 at EncryptCookies->handle() in Pipeline.php line 136 at call_user_func_array:{C:\wamp\www\social\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:136}() in Pipeline.php line 136 at Pipeline->Illuminate\Pipeline\{closure}() in Pipeline.php line 32 at call_user_func:{C:\wamp\www\social\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:32}() in Pipeline.php line 32 at Pipeline->Illuminate\Routing\{closure}() in Pipeline.php line 103 at call_user_func:{C:\wamp\www\social\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:103}() in Pipeline.php line 103 at Pipeline->then() in Router.php line 726 at Router->runRouteWithinStack() in Router.php line 699 at Router->dispatchToRoute() in Router.php line 675 at Router->dispatch() in Kernel.php line 246 at Kernel->Illuminate\Foundation\Http\{closure}() in Pipeline.php line 52 at call_user_func:{C:\wamp\www\social\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:52}() in Pipeline.php line 52 at Pipeline->Illuminate\Routing\{closure}() in CheckForMaintenanceMode.php line 44 at CheckForMaintenanceMode->handle() in Pipeline.php line 136 at call_user_func_array:{C:\wamp\www\social\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:136}() in Pipeline.php line 136 at Pipeline->Illuminate\Pipeline\{closure}() in Pipeline.php line 32 at call_user_func:{C:\wamp\www\social\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:32}() in Pipeline.php line 32 at Pipeline->Illuminate\Routing\{closure}() in Pipeline.php line 103 at call_user_func:{C:\wamp\www\social\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:103}() in Pipeline.php line 103 at Pipeline->then() in Kernel.php line 132 at Kernel->sendRequestThroughRouter() in Kernel.php line 99 at Kernel->handle() in index.php line 54 in server.php line 21 at {main}() in server.php line 0
Начиная с Laravel 5.2, все маршруты завернуты с помощью Web Middleware
, поэтому нет причин определять Route::group(['middleware' => ['web']);
больше.
В RouteServiceProvider:
protected function mapWebRoutes(Router $router) { $router->group([ 'namespace' => $this->namespace, 'middleware' => 'web', ], function ($router) { require app_path('Http/routes.php'); }); }
Это экземпляр предыдущей функции в том же файле:
public function map(Router $router) { $this->mapWebRoutes($router); // }
Это называется стеком Kernel
.
Это должно решить проблему гнездования.