关于php artisan配置的Laravel 5:清除生成的Closure :: __ set_state()错误

Tar*_*unn 16 php laravel-5

我生产的代码和我跑了

php artisan config:clear
Run Code Online (Sandbox Code Playgroud)

之后,我的代码没有运行.索引页面和所有其他页面都显示为白屏,并在firebug中显示500内部服务器错误.当我试图跑

php artisan
Run Code Online (Sandbox Code Playgroud)

它给了我错误

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

我的代码正在生产中!! 之前没有/vendor/config.php文件,该代码发生了什么?你有没有遇到过这样的错误?我已经授予存储/文件夹和vendor /的所有权限.任何帮助/指南将不胜感激.

gec*_*kob 20

我跑的时候遇到过类似的问题php artisan config:cache.显然,当应用程序尝试加载其中包含闭包的缓存配置文件时,这是一个问题.它不会在Laravel中修复,因为在配置文件中使用闭包是一种不好的做法.请参阅此Github 问题

我解决这个问题的方法是撤消这个.

删除配置缓存.

它位于这里

bootstrap/cache/config.php

要么

vendor/config.php


小智 19

我曾面临类似的问题在过去不知道什么原因造成的,但到现在为止,你可以删除config.php/vendor它不会破坏你的代码.

你的代码将开始工作..

  • 这个解决方案只有一次,当你运行代码`php artisan config:cache`第二次它会再次弹出错误 (3认同)

Ben*_*son 8

在其他根本原因中,php artisan config:cache当在Laravel尝试加载的任何配置文件中定义闭包时调用此错误.Laravel不允许在配置文件中关闭; 看到:

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

删除生成的缓存文件(通常位于)bootstrap/cache/config.php,"修复"错误.

长期解决方案是消除所有配置文件中的闭包.可以通过检查有问题的行来确定有问题的配置文件,如错误消息中所述.

如果违规文件是第三方,最好打开库的问题,以便在上游修复问题.


Kal*_*Kal 6

以下是我要解决的问题:

  1. 转到/vendor/tymon/jwt-auth/src/config/config.php和更换线storageauth用:

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

  1. 转到/bootstrap/cache/config.php并删除它
  2. 按顺序运行以下命令:
    A)php artisan config/cache
    B)php artisan jwt:generate
    C)php artisan vendor:publish --provider="Tymon\JWTAuth\Providers\JWTAuthServiceProvider"

应该这样做!