Web中间件中带有TwigBridge的Laravel 5.2导致达到最大功能嵌套级别“100”

时间:2016-01-26 16:17:46

标签: php laravel twig laravel-5.2

我有这个简单的控制器:

<?php
namespace App\Http\Controllers;

use Illuminate\Routing\Controller;
use Illuminate\Http\Request;

class TestController extends Controller
{
    public function indexAction(Request $request)
    {
        return view('test');
    }
}

加载这个简单的视图:

<!DOCTYPE html>
<html>
    <head>
        <title>Hello World!</title>
    </head>
    <body>
        <h1>Hello World!</h1>
    </body>
</html>

当我把它放在像这样的网络中间件时,我收到Maximum function nesting level...错误:

Route::group(['middleware' => ['web']], function () {
    Route::get('/test', 'TestController@indexAction');
});

如果我从中间件中取出路线它可以正常工作。我想这是TwigBridge的一个问题,但我没有看到其他人报告它。在我的设置中有什么我可能错过的吗?

修改

显然我必须解释为什么这不是另一个问题的重复。这是Laravel 5.2和TwigBridge插件特有的。它作为源代码的一部分出现。引用可能重复的项目与Laravel和TwigBridge无关。可以通过多种方式生成此特定错误。它来自xdebug。我只是想问一下Laravel,TwigBridge或我的代码是什么导致了这个错误。

编辑2

这是我要求的Kernel.php文件:

<?php

namespace App\Http;

use Illuminate\Foundation\Http\Kernel as HttpKernel;

class Kernel extends HttpKernel
{
    /**
     * The application's global HTTP middleware stack.
     *
     * These middleware are run during every request to your application.
     *
     * @var array
     */
    protected $middleware = [
        \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
    ];

    /**
     * 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,
        ],

        'api' => [
            'throttle:60,1',
        ],
    ];

    /**
     * The application's route middleware.
     *
     * These middleware may be assigned to groups or used individually.
     *
     * @var array
     */
    protected $routeMiddleware = [
        'auth' => \App\Http\Middleware\Authenticate::class,
        'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
        'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
        'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
    ];
}

0 个答案:

没有答案