RouteRegistrar.php 第 75 行中的 Laravel InvalidArgumentException:

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42481954/
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 15:25:16  来源:igfitidea点击:

Laravel InvalidArgumentException in RouteRegistrar.php line 75:

phplaravelinvalidargumentexception

提问by Lloyd

I keep getting this error when trying to deploy a laravel application to a production server:

尝试将 Laravel 应用程序部署到生产服务器时,我不断收到此错误:

InvalidArgumentException in RouteRegistrar.php line 75:

InvalidArgumentException in RouteRegistrar.php line 75:

in RouteRegistrar.php line 75
at RouteRegistrar->attribute('after', object(AfterFilter)) in Router.php line 1085
at Router->__call('after', array(object(AfterFilter))) in BootProviders.php line 17
at Router->after(object(AfterFilter)) in BootProviders.php line 17
at Application->boot() in BootProviders.php line 17
at BootProviders->bootstrap(object(Application)) in Application.php line 208
at Application->bootstrapWith(array('Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables', 'Illuminate\Foundation\Bootstrap\LoadConfiguration', 'Illuminate\Foundation\Bootstrap\HandleExceptions', 'Illuminate\Foundation\Bootstrap\RegisterFacades', 'Illuminate\Foundation\Bootstrap\RegisterProviders', 'Illuminate\Foundation\Bootstrap\BootProviders')) in Kernel.php line 160
at Kernel->bootstrap() in Kernel.php line 144
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 116
at Kernel->handle(object(Request)) in index.php line 54

The strange thing is that I do not get this error on my local machine. The PHP version of my machine and the production server is nearly identical (5.6.25 on the server and 5.6.26 on my machine).

奇怪的是我在本地机器上没有收到这个错误。我的机器和生产服务器的 PHP 版本几乎相同(服务器上的 5.6.25 和我的机器上的 5.6.26)。

Does anyone have any idea what could be causing this error?

有谁知道是什么导致了这个错误?

采纳答案by Lloyd

After some more research the source of the problem seems to be an old version of New Relic that was installed on the server. https://discuss.newrelic.com/t/php-agent-breaks-laravel-5-2/32801

经过更多研究,问题的根源似乎是安装在服务器上的旧版 New Relic。 https://discuss.newrelic.com/t/php-agent-breaks-laravel-5-2/32801

回答by PeterPan666

This exception should throw a message like Attribute [{$key}] does not exist., you need to find this key and fix it. It seems that you are not using a correct key name, you can find the allowed ones here.

这个异常应该抛出一个类似的消息Attribute [{$key}] does not exist.,你需要找到这个键并修复它。您似乎没有使用正确的密钥名称,您可以在此处找到允许的名称。

protected $allowedAttributes = [
    'as', 'domain', 'middleware', 'name', 'namespace', 'prefix',
];

The method that throws this exception is the attributein the RouteRegistrar.phpfile.

抛出此异常的方法attributeRouteRegistrar.php文件中。