[英]Problems with creating subfolders in CodeIgniter 3 HMVC
我有一個包含幾個子文件夾的項目,例如:
我這樣設置路線:
$route['default_controller'] = "admin/signin/signin";
$route['admin/sigin'] = "admin/sigin/signin/index";
$route['admin/(:any)'] = "admin/sigin/signin/";
$route['client/auth'] = "auth/login/login";
這些路由不起作用,顯示CodeIgniter 404錯誤頁面。
$route['default_controller'] = "admin/signin/signin";
$route['admin/signin'] = "admin/signin/signin/index";
$route['admin/(:any)'] = "admin/signin/signin/$1";
$route['client/auth'] = "auth/login/login";
修正了上面的錯字。 而且我認為您的文件結構不正確。 我使用CI2,不確定模塊如何在CI3中工作。 但是模塊“ forgot_password”和“ signin”將使用相同的模型,對嗎? 為什么要將它們放在單獨的文件夾/模塊中? 這樣,當您對User模型進行更改時,就必須在所有模塊中的每個User模型中進行更改(除非您在那種情況下不需要它,但我仍然不會冒着構建自己的應用程序的風險)那)
- modules
- Admin
- controllers
- user.php // Will have methods like signin(), add(), view(),...
- Client
- controllers
- auth.php // Will have methods like signin(), signout(), ...
- models // This will hold models you don't need in Admin module
// other models should be in the default models folder, so each module will be able to access them.
路線如下所示:
$route['default_controller'] = "admin/user/signin"; // admin module, user controller, signin method
$route['admin/signin'] = "admin/user/signin";
$route['admin/(:any)'] = "admin/content/$1"; // admin module, content controller, (:any) method (content being an example, I have it in my CMS project)
$route['client/auth'] = "client/auth/login"; // client module, auth controller, login method
我解決了..在配置文件中,我添加了以下代碼行;
$config['modules_locations'] = array(
APPPATH.'modules/' => '../modules/',
APPPATH.'modules/admin/' => '../modules/admin/',
APPPATH.'modules/client/' => '../modules/client/',
);
它就像一個魅力.. :)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.