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

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

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!