Call to a member function get() on null怎么解决啊?

zhuyujin001

问题描述

这里详细描述问题
webman在config文件下的captcha.php里这样写

declare(strict_types=1);
use support\Container;
use think\facade\Cache;
return[
"option"=>Container::get(Cache::class),

];

然后就报错了,这怎么解决啊?

558 2 0
2个回答

Gin
walkor

因为载入配置的时候Container还没有初始化,所以是null。

  • zhuyujin001 2023-05-10

    谢谢,想问下:旧项目tp6里config下的captcha.php里用了return [ "option"=> app()->make(Cache::class) ] 我把旧项目改成webman的话,这块怎么写啊?

  • walkor 2023-05-10

    直接new 试下

🔝