How to Use Module Controllers in Kohana 3?

情到浓时终转凉″ 提交于 2019-12-24 17:28:45

问题


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:


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



来源:https://stackoverflow.com/questions/5444286/how-to-use-module-controllers-in-kohana-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!