Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5 on php artisan config:clear generated Closure::__set_state() error

Tags:

php

laravel-5

My code in on production and I ran

php artisan config:clear

After that, my code was not running. The index pages and all other pages went white screen and gave 500 internal server error in firebug. When I tried to run

php artisan

it gave me error as

PHP Fatal error:  Call to undefined method Closure::__set_state() in /var/www/live/vendor/config.php on line 56

My code is in production!! /vendor/config.php file was not present before, what happened with that code?? Have you faced any such error? I had given all permissions to storage/ folder and vendor/. Any help/guide would be much appreciated.

like image 828
Tarunn Avatar asked Jul 01 '15 06:07

Tarunn


3 Answers

I had similar issues when I ran php artisan config:cache. Apparently, it is an issue when the application is trying to load cached configuration files that have closures in it. It won't be fixed in Laravel since it is a bad practice to have closures in config files. Refer this Github issue

The way I solved this is by undo-ing this.

Delete the cache for config.

It is located in here

bootstrap/cache/config.php

OR

vendor/config.php

like image 183
geckob Avatar answered Nov 17 '22 02:11

geckob


I had faced the similar issue in past don't know what caused it but as of now you can delete the config.php from /vendor it won't break your code.

And your code will be start working..

like image 24
Jaimin Avatar answered Nov 17 '22 04:11

Jaimin


Among other root-causes, this error results from calling php artisan config:cache when a closure is defined inside any configuration file that Laravel attempts to load. Laravel does not allow for closures in configuration files; see:

https://github.com/laravel/framework/issues/9625

Deleting the resultant cache file, usually located at bootstrap/cache/config.php, "fixes" the error.

The long-term solution is to eliminate closures from all configuration files. The problematic config file can be determined by inspecting the offending line, as mentioned in the error message.

If the offending file is third-party, it is best to open an issue with the library, so that the issue is fixed upstream.

like image 8
Ben Johnson Avatar answered Nov 17 '22 03:11

Ben Johnson