How can I create the Route in Kohana 3.2 for this directory structure: /application/my_use_case/classes/

三世轮回 提交于 2019-12-04 06:43:47

问题


I'm using Kohana 3.2 and I need to create the directory structure below for my application. For that, I'm using the Route below, but I'm doing something wrong yet. "Settings" is my use case that I'm developing.

<?php
Route::set('global', '<directory>(/<controller>(/<action>))', array('directory' => 'settings'))
    ->defaults(array(
        'directory' => 'settings',
        'controller' => 'settings',
        'action' => 'index',
    ));
?>

So, this is my directory structure for "Settings" use case:

   - ..\application\settings\classes\controller\settings.php
   - ..\application\settings\classes\model\settings.php
   - ..\application\settings\views\settings_form.php

And this is the code for my controller:

   class Controller_Settings extends Controller {

       public function action_index(){
           echo 'test';
       }
   }

And this is the url that I'm using to access my controller:

   - http://cmx107/clients/cmcaapp/v1/settings

Thanks, Cheers


回答1:


Since you set directory to default to settings, you need to put your controller Settings in the Settings directory like this rather than the way you did it:

Paths

Correct: application/classes/settings/settings.php

Format: apppath/classes/<directory>/<controller>.php

Class Controller_Settings_Settings extends Controller {
    public function action_index(){
       echo 'test';
   }
}


来源:https://stackoverflow.com/questions/10075558/how-can-i-create-the-route-in-kohana-3-2-for-this-directory-structure-applicat

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