dou12352 2011-03-26 18:20
浏览 26
已采纳

如何在Kohana 3中使用模块控制器?

For the following application directory structure under / in Kohana 3:

  • application

    • classes
    • controller
      • controller1.php
  • modules

    • admin
    • classes
      • controller
      • controller2.php

And the urls be: /controller1 and /admin/controller2?

I seem to be missing something though because I keep getting a 404 error with the /admin/controller. What am I doing incorrectly?

The exact error is:

HTTP_Exception_404 [ 404 ]: The requested URL admin/borrowers was not found on this server.

And I don't have any custom routes setup. This is a very vanilla K3 install at this point.

  • 写回答

1条回答 默认 最新

  • douhuang2673 2011-03-26 19:12
    关注

    The directory structure seems to be a little of.

    Using a module doesn't automatically means you have a subdirectory. The default route defines the following url structure:

    /[controller]/[action]
    

    So for the directory structure that you have given, you get the following:

    /controller2/
    

    The action can be left out, but it will default to index.

    If you want a special admin subdirectory, you would first have to create that subdirectory in you modules classes directory like this:

    /admin/classes/admin/controller2.php
    

    Then you would have to add another route that handles the subdirectory. You can find more information about that in the userguide

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 python进程启动打包问题
  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入
  • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。
  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥15 无线移动边缘计算系统中的系统模型
  • ¥15 深度学习中的画图问题