找不到AssetBundle依赖类

时间:2016-04-28 11:01:43

标签: php yii2 assets

我在名为@app/assets/dependencies的{​​{1}}中创建了一个依赖项,其UikitDependency.php名称空间为app\assets\dependencies

namespace app\assets\dependencies;

use yii\web\AssetBundle;

class UikitDependency extends AssetBundle
{
    public $sourcePath = '@bower/uikit/';
    public $css = [
        'css/uikit.almost-flat.min.css',
    ];
}

然后我尝试将此依赖项添加到@app/assets资产,其名称为MainAppAsset.php,名称空间为app\assets,代码如下:

public $depends = [
    'assets/dependencies/UikitDependency'
];

毕竟它向我显示错误说: 类资产/依赖项/ UikitDependency不存在

我也试过了:

public $depends = [
    'dependencies/UikitDependency'
];

public $depends = [
    '@app/assets/dependencies/UikitDependency'
];

我在这里询问的那一刻,我没有找到任何有关依赖路径的文档。感谢

1 个答案:

答案 0 :(得分:0)

应该是

public $depends = [
    'app\assets\dependencies\UikitDependency'
];

命名空间是PHP中类名的一部分。