Laravel RouteRegistrar.php 第 75 行中的 InvalidArgumentException:

Laravel InvalidArgumentException in RouteRegistrar.php line 75:

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

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

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

有谁知道可能导致此错误的原因吗?

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

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

抛出这个异常的方法是RouteRegistrar.php文件中的attribute

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