laravel5.5 Call to undefined method Closure::__set_state()

淡淡的烟草味﹌ 2022-04-14 04:09 283阅读 0赞

文章目录

      • 场景
      • 分析
      • 解决

场景

  • 今天想要缓存下配置文件, php artisan config:cache; 然后在执行其他的php artisan 命令的时候发现 Call to undefined method Closure::__set_state()

分析

  • 根据错误提示定位到代码, 这个是在配置dingo/api的时候引入匿名函数导致的

    // 配置文件 bootstrap/cache/config.php

    1. array (
    2. 'basic' =>
    3. Closure::__set_state(array(
    4. )),
    5. 'jwt' => 'Dingo\\Api\\Auth\\Provider\\JWT',
    6. ),

    // config/api.php

    1. 'auth' => [
    2. 'basic' => function($app){
    3. return new Dingo\Api\Auth\Provider\Basic($app['auth']);
    4. },
    5. 'jwt' => 'Dingo\Api\Auth\Provider\JWT',
    6. ],

解决

  • jwt配置修改, 删掉缓存文件,重新缓存

    config/api.php

    1. 'auth' => [
    2. 'basic' => '\Dingo\Api\Auth\Provider\Basic',
    3. 'jwt' => 'Dingo\Api\Auth\Provider\JWT',
    4. ],

发表评论

表情:
评论列表 (有 0 条评论,283人围观)

还没有评论,来说两句吧...

相关阅读