21

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.

Tarunn
  • 1,038
  • 3
  • 23
  • 45

8 Answers8

31

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

geckob
  • 7,680
  • 5
  • 30
  • 39
  • I'm not sure that this adds anything to the Answer that I posted two weeks earlier (but maybe I'm wrong, given the upvotes). Just sayin'. :) – Ben Johnson Oct 19 '17 at 16:08
  • [@Ben Johnson](https://stackoverflow.com/users/1772379/ben-johnson) Honestly, I think his answer was formatted so you could get to the solution faster. I am upvoting your answer too because you put in a little more effort :-) – yardpenalty.com Mar 09 '19 at 23:01
24

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

Jaimin
  • 872
  • 6
  • 15
  • 3
    This solution is just for one time, when you run the code `php artisan config:cache` the 2nd time it will pop up the error again – Mahmoud Kassem Jan 08 '18 at 02:28
8

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.

Ben Johnson
  • 2,507
  • 3
  • 29
  • 29
7

Here is what I did to solve it:

  1. Go to /vendor/tymon/jwt-auth/src/config/config.php and replace the lines for storage and auth with:

'auth' => 'Tymon\JWTAuth\Providers\Auth\IlluminateAuthAdapter',
'storage' => 'Tymon\JWTAuth\Providers\Storage\IlluminateCacheAdapter'

  1. Go to /bootstrap/cache/config.php and delete it
  2. Run the following commands in order:
    A) php artisan config/cache
    B) php artisan jwt:generate
    C) php artisan vendor:publish --provider="Tymon\JWTAuth\Providers\JWTAuthServiceProvider"

and that should do it!

Brane
  • 3,257
  • 2
  • 42
  • 53
Kal
  • 948
  • 17
  • 30
4

Try to remove the config.php from bootstrap/cache folder. It worked for me.

giapnh
  • 2,950
  • 24
  • 20
  • 1
    Super helpful! Thanks. I ran `mv bootstrap/cache/config.php bootstrap/cache/config_old.php` and then `php artisan config:clear` – Ryan Aug 12 '19 at 16:19
0

Edit vendor\laravel\framework\src\Illuminate\Foundation\Support\Providers\RouteServiceProvider.php:108 and delete required.

James Risner
  • 5,451
  • 11
  • 25
  • 47
teddy 225
  • 81
  • 1
-1

Changing the config.php file inside the vendor/tymon/jwt-auth/src/config to this

'auth' => Tymon\JWTAuth\Providers\Auth\IlluminateAuthAdapter::class` 

and this

'storage' => Tymon\JWTAuth\Providers\Storage\IlluminateCacheAdapter::class` 

before runnning php artisan config:cache worked for me.

cchapman
  • 3,269
  • 10
  • 50
  • 68
-1

solved using

composer update

composer install
Saurabh Mistry
  • 12,833
  • 5
  • 50
  • 71