yii2高级模板添加新增模块

例, 增加一个 API 的专用模块,在系统初始化的时候 修改 environments\index.php 文件,如下:

return [
    'Development' => [
        'path' => 'dev',
        'setWritable' => [    // 设置可写目录
            'api/runtime',      
            'api/web/assets',
            'api/controllers',   //当前目录设置为可写为 Gii 使用,所以生产环境不需要配置
            'api/models',        //当前目录设置为可写为 Gii 使用,所以生产环境不需要配置
            'backend/controllers',  //当前目录设置为可写为 Gii 使用,所以生产环境不需要配置
            'backend/models',    //当前目录设置为可写为 Gii 使用,所以生产环境不需要配置
            'backend/runtime',
            'backend/web/assets',
            'frontend/controllers',   //当前目录设置为可写为 Gii 使用,所以生产环境不需要配置
            'frontend/models',       //当前目录设置为可写为 Gii 使用,所以生产环境不需要配置
            'frontend/runtime',
            'frontend/web/assets',
        ],
        'setExecutable' => [
            'yii',
            'tests/codeception/bin/yii',
        ],
        'setCookieValidationKey' => [
            'api/config/main-local.php',
            'backend/config/main-local.php',
            'frontend/config/main-local.php',
        ],
    ],
    'Production' => [
        'path' => 'prod',
        'setWritable' => [
            'api/runtime',
            'api/web/assets',
            'backend/runtime',
            'backend/web/assets',
            'frontend/runtime',
            'frontend/web/assets',
        ],
        'setExecutable' => [
            'yii',
        ],
        'setCookieValidationKey' => [
            'api/config/main-local.php',
            'backend/config/main-local.php',
            'frontend/config/main-local.php',
        ],
    ],
];


后期也可以增加,命令行情况下重新执行根目录下的 init  文件即可,注意不要重写了配置文件



你可能感兴趣的:(yii2高级模板添加新增模块)