【发布时间】:2021-06-24 10:11:36
【问题描述】:
我使用 composer 安装了这个 plugin。
Flags.php 类在vendor/filsh/yii2-flags/yii/flags/ 目录中
当我在我的视图中添加这个时
use filsh\yii2flags\yii\flags\Flags;
echo Flags::widget([
'flag' => 'UA',
'type' => Flags::FLAT_24,
'useSprite' => false // use sprite image? default is false
]);
我收到 Class 'filsh\yii2flags\yii\flags\Flags' not found 错误。
我也尝试了use vendor\filsh\yii2flags\yii\flags\Flags;,但仍然没有运气。
我在这里做错了什么?谢谢。
【问题讨论】:
-
试试
use yii\flags\Flags -
@InsaneSkull 谢谢。能帮忙解释一下为什么吗? use 不应该是类的目录吗?
-
在插件的composer中映射了如何创建命名空间See here
-
类的命名空间在定义类的文件中定义。 See source composer.json 中的设置仅用于设置映射命名空间到文件夹以供作曲家生成自动加载。