我有一个新的Laravel 5.2安装(osx:10.11,php:5.6)。当我创建一个新的中间件(LocaleMiddleware.php)时,Laravel崩溃了:
' 100'的最大功能嵌套级别到达,流产!
最让我担心的是,即使新的中间件有一个空的/注释掉的函数体,我的应用程序也会崩溃!
kernel.php
...
/**
* The application's route middleware groups.
*
* @var array
*/
protected $middlewareGroups = [
'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,
\App\Http\Middleware\LocaleMiddleware::class, //<-- My Middleware
],
'api' => [
'throttle:60,1',
],
];
LocaleMiddleware.php,即使函数体被注释掉,它也会崩溃我的应用程序:
<?php
namespace App\Http\Middleware;
use Illuminate\Support\Facades\Session;
use Closure;
class LocaleMiddleware
{
/**
* Run the request filter.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next) {
// $language = Session::get('language');
// //print_r(Session::all());
// \App::setLocale($language, config('app.locale'));
return $next($request);
}
}
错误:
in Autoloader.php line 72
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 PHPExcel_Autoloader::Load() in ClassLoader.php line 0
at spl_autoload_call() in ClassLoader.php line 29
in ClassLoader.php line 412
at Composer\Autoload\includeFile() in ClassLoader.php line 301
at ClassLoader->loadClass() in Parser.php line 0
at spl_autoload_call() in Parser.php line 45
at Tokenizer->__construct() in Parser.php line 42
at Parser->__construct() in Translator.php line 78
at Translator->__construct() in CssSelectorConverter.php line 36
at CssSelectorConverter->__construct() in CssToInlineStyles.php line 20
at CssToInlineStyles->__construct() in ExcelServiceProvider.php line 111
at ExcelServiceProvider->Maatwebsite\Excel\{closure}() in Container.php line 731
at Container->build() in Container.php line 629
at Container->make() in Application.php line 697
at Application->make() in Container.php line 1178
at Container->offsetGet() in Container.php line 136
at ExcelServiceProvider->Maatwebsite\Excel\{closure}() in Container.php line 731
at Container->build() in Container.php line 629
at Container->make() in Application.php line 697
at Application->make() in Container.php line 1178
at Container->offsetGet() in Container.php line 151
at ExcelServiceProvider->Maatwebsite\Excel\{closure}() in Container.php line 731
at Container->build() in Container.php line 629
at Container->make() in Application.php line 697
at Application->make() in Container.php line 1178
at Container->offsetGet() in Container.php line 186
at ExcelServiceProvider->Maatwebsite\Excel\{closure}() in Container.php line 731
at Container->build() in Container.php line 629
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 SubcategoryController.php line 19
at Excel::load() in SubcategoryController.php line 19
at SubcategoryController->start() in Controller.php line 80
at call_user_func_array:{/Websites/Heuss/lheuss/vendor/laravel/framework/src/Illuminate/Routing/Controller.php:80}() in Controller.php line 80
at Controller->callAction() in ControllerDispatcher.php line 146
at ControllerDispatcher->call() in ControllerDispatcher.php line 94
at ControllerDispatcher->Illuminate\Routing\{closure}() in Pipeline.php line 52
at call_user_func:{/Websites/Heuss/lheuss/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:52}() in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}() in Pipeline.php line 103
at call_user_func:{/Websites/Heuss/lheuss/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:103}() in Pipeline.php line 103
at Pipeline->then() in ControllerDispatcher.php line 96
at ControllerDispatcher->callWithinStack() in ControllerDispatcher.php line 54
at ControllerDispatcher->dispatch() in Route.php line 174
at Route->runController() in Route.php line 140
at Route->run() in Router.php line 724
at Router->Illuminate\Routing\{closure}() in Pipeline.php line 52
at call_user_func:{/Websites/Heuss/lheuss/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:52}() in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}() in LocaleMiddleware.php line 22
at LocaleMiddleware->handle() in Pipeline.php line 136
at call_user_func_array:{/Websites/Heuss/lheuss/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:{/Websites/Heuss/lheuss/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:{/Websites/Heuss/lheuss/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:{/Websites/Heuss/lheuss/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:{/Websites/Heuss/lheuss/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:{/Websites/Heuss/lheuss/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:32}() in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}() in StartSession.php line 64
at StartSession->handle() in Pipeline.php line 136
at call_user_func_array:{/Websites/Heuss/lheuss/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:{/Websites/Heuss/lheuss/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:{/Websites/Heuss/lheuss/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:{/Websites/Heuss/lheuss/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:{/Websites/Heuss/lheuss/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:{/Websites/Heuss/lheuss/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:{/Websites/Heuss/lheuss/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:{/Websites/Heuss/lheuss/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:{/Websites/Heuss/lheuss/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:{/Websites/Heuss/lheuss/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:{/Websites/Heuss/lheuss/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
at {main}() in index.php line 0
答案 0 :(得分:0)
问题不在你的中间件中 - 看看堆栈,你的应用程序进入中间件并进入SubcategoryController
。看起来好像在ExcelServiceProvider
的闭包中发生了一些事情,所以请检查一下。