您的配置文件不可序列化

Bre*_*dan 4 config laravel-5

我跑了

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

在我的终端上,我得到了LogicException

LogicException  : Your configuration files are not serializable.

at C:\xampp\htdocs\penschool\vendor\laravel\framework\src\Illuminate\Foundation\Console\ConfigCacheCommand.php:68

 64|             require $configPath;
 65|         } catch (Throwable $e) {
 66|             $this->files->delete($configPath);
 67|
 68|             throw new LogicException('Your configuration files are not serializable.', 0, $e);
 69|         }
 70|
 71|         $this->info('Configuration cached successfully!');
 72|     }

 Exception trace:

1   Error::("Call to undefined method Closure::__set_state()")
  C:\xampp\htdocs\penschool\bootstrap\cache\config.php:241

2   require()
  C:\xampp\htdocs\penschool\vendor\laravel\framework\src\Illuminate\Foundation\Console\ConfigCacheCommand.php:64

Please use the argument -v to see more details.
Run Code Online (Sandbox Code Playgroud)

在运行此命令之前,我从未遇到过此错误。请任何帮助将不胜感激。谢谢。

Chu*_*nya 14

Laravel 和 PHP 中不允许闭包序列化。查看您的配置文件中使用了闭包的任何文件,并使用传统函数重写那段代码。


And*_*dré 7

找出确切的问题是,你可以暂时删除$this->files->delete($configPath);vendor/laravel/framework/src/Illuminate/Foundation/Console/ConfigCacheCommand.php。这样bootstrap/cache/config.php做不会自动删除,您可以在config.php文件中查找提到的行(此处为241)。