其實非常簡單,不過開發文檔沒有細說
修改public/index.php文件如下:
// 定義應用目錄 define('APP_PATH', __DIR__ . '/../application/'); // 加載框架引導文件 require __DIR__ . '/../thinkphp/start.php'; \think\Build::module('admin');
修改build.php文件如下:
return [ // 生成應用公共文件 '__file__' => ['common.php', 'config.php', 'database.php'], // 定義demo模塊的自動生成 (按照實際定義的文件名生成) 'index' => [ '__file__' => ['common.php'], '__dir__' => ['behavior', 'controller', 'model', 'view'], 'controller' => ['Index', 'Test', 'UserType'], 'model' => ['User', 'UserType'], 'view' => ['index/index'], ], 'admin' => [ '__file__' => ['common.php'], '__dir__' => ['behavior', 'controller', 'model', 'view'], 'controller' => ['Index', 'Test', 'UserType'], 'model' => ['User', 'UserType'], 'view' => ['index/index'], ], // 其他更多的模塊定義 ];
保存以上配置,然后運行首頁 即可生成 新的 admin 模塊