简体   繁体   English

Yii2我们可以更改资产目录位置吗?

[英]Yii2 Can we change the assets directory location?

Yii2 automatically generates the assets in web folder. Yii2自动在Web文件夹中生成资源。 How can we change it to any other folder? 我们如何将其更改为任何其他文件夹?

For example. 例如。 If I create a folder named myassets in web folder. 如果我在web文件夹中创建名为myassets的文件夹。 It is possible to store all the assets in this folder? 可以将所有资产存储在此文件夹中吗?

You can change it by editing $basePath of AssetManager . 您可以通过编辑AssetManager的 $ basePath来更改它。

Through application config: 通过应用配置:

'assetManager' => [
    'basePath' => '@webroot/my-assets',
],

Through application component: 通过申请组件:

\Yii:$app->assetManager->basePath = '@webroot/my-assets';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM