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

后端 未结 7 945
情书的邮戳
情书的邮戳 2020-12-24 02:50

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

相关标签:
7条回答
  • 2020-12-24 03:28

    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.

    0 讨论(0)
  • 2020-12-24 03:32

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

    0 讨论(0)
  • 2020-12-24 03:33

    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!

    0 讨论(0)
  • 2020-12-24 03:42

    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.

    0 讨论(0)
  • 2020-12-24 03:48

    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

    0 讨论(0)
  • 2020-12-24 03:50

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

    0 讨论(0)
提交回复
热议问题