dongshou1991 2018-04-16 10:54
浏览 32

在CodeIgniter 3 HMVC中创建子文件夹的问题

I have a project that contains several subfolders, such as:

  1. client/auth/login = model/view/controller
  2. client/auth/signup = model/view/controller
  3. admin/signin = model/view/controller

I set up my routes like this:

$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";

These routes are not working, which shows CodeIgniter 404 error page.

  • 写回答

2条回答 默认 最新

  • dqjcb132285 2018-04-17 09:06
    关注
    $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";
    

    Fixed typo's above. And I think your file structure is not correct. I use CI2, not sure how modules work in CI3. But the modules 'forgot_password' and 'signin' would be using the same models right? Why having them in separate folders/modules? This way when you make a change to the User model, you'll have to make the change in every User model in all modules (unless you don't need it in that cases, but still I wouldn't risk building my app like that)

    - 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.
    

    The routes would look like this:

    $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
    
    评论

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改