1

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

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).

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

Filip
  • 129
  • 2
  • 8
  • Which version of Laravel are you using? Do you have a valid .env file? What are the steps of your deployment? – Elie Faës Feb 27 '17 at 09:29
  • Laravel v5.4 .env file is present and valid. The code is cloned from a git repository and after that "composer install" is executed. The error occurs when it tries to run "php artisan optimize". But I also get the error on the page itself. – Filip Feb 27 '17 at 09:38
  • Is it when you deploy or when you try to access your website? – Elie Faës Feb 27 '17 at 09:40
  • On both occasions. When I try to access the website I get that error and when I try to do any php artisan commands in the command line I get the same error. – Filip Feb 27 '17 at 09:46

2 Answers2

2

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.

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

The method that throws this exception is the attribute in the RouteRegistrar.php file.

Elie Faës
  • 3,215
  • 1
  • 25
  • 41
  • Yes it does throw this message: "Attribute [after] does not exist.". But the issue is that it isn't my code that is generating this issue. I also get the issue with a stock laravel 5.4 install. – Filip Feb 27 '17 at 11:18
  • Are you using any other package in your Laravel app? – Elie Faës Feb 27 '17 at 12:52
  • In the complete application I am using other packages yes. That is why I tried it with a stock Laravel installation to see if it were my packages that caused the issue. I have since tried to install it on a server with similar settings but with a higher php version (5.6.28). And on that server it works. – Filip Feb 28 '17 at 12:30
1

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

Filip
  • 129
  • 2
  • 8