Laravel 在非对象上调用成员函数 parameters()

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32134412/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 12:13:50  来源:igfitidea点击:

Laravel Call to a member function parameters() on a non-object

phplaravellogging

提问by Ghassan Zein

Am having this problem and not able to find any solution for that, please help:

我遇到了这个问题并且无法找到任何解决方案,请帮助:

exception Symfony\Component\Debug\Exception\FatalErrorExceptionwith message Call to a member function parameters() on a non-object

Symfony\Component\Debug\Exception\FatalErrorException消息异常Call to a member function parameters() on a non-object

The error is on the: "$route->parameters()"

错误在:“$route->parameters()”

 protected function substituteBindings($route)
    {
            foreach ($route->parameters() as $key => $value)
            {
                    if (isset($this->binders[$key]))
                    {
                            $route->setParameter($key, $this->performBinding($key, $value, $route));
                    }
            }

            return $route;
    }

Am receiving tons of this same error anytime i use the app. any suggestions?

每当我使用该应用程序时,都会收到大量相同的错误。有什么建议?

回答by Mantas D

By fallowing Laravel documentation I have added SubtituteBindings to $middleware array. But I needed to add it to $middlewareGroups array. Documentation is a bit not clear on that.

通过闲置 Laravel 文档,我已将 SubtituteBindings 添加到 $middleware 数组。但是我需要将它添加到 $middlewareGroups 数组中。文档对此有点不清楚。

回答by Mostafa Lavaei

I think you upgrade your Laravel! I dont know why, but if you remove SubstituteBindingsfrom $middlewareand webat app\Http\Middlewares\Kernel.phpeverything will works!

我想你升级了你的 Laravel!我不知道为什么,但如果你删除SubstituteBindings$middleware,并webapp\Http\Middlewares\Kernel.php一切都会作品!

回答by Sahin S.

I'm coming from Laravel 4.2 to 5.3 .. :) I got this error:

我从 Laravel 4.2 到 5.3 .. :) 我收到这个错误:

FatalErrorException in Router.php line 781: Call to a member function parameters() on null

Similar with the main error. Reason is typo and/or misconfiguration (after/before upgrading), replace the **$middlewareGroups ** lines with as:

与主要错误类似。原因是拼写错误和/或配置错误(升级之后/之前),将 **$middlewareGroups ** 行替换为:

protected $middlewareGroups = [
    'web' => [
        \App\Http\Middleware\EncryptCookies::class,
        \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
        \Illuminate\Session\Middleware\StartSession::class,
        // \Illuminate\Session\Middleware\AuthenticateSession::class,
        \Illuminate\View\Middleware\ShareErrorsFromSession::class,
        \App\Http\Middleware\VerifyCsrfToken::class,
        \Illuminate\Routing\Middleware\SubstituteBindings::class,
    ],

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

That's it!

就是这样!