如何在Kohana 3.2中为此目录结构创建Route:/ application / my_use_case / classes / [英] How can I create the Route in Kohana 3.2 for this directory structure: /application/my_use_case/classes/

查看:258
本文介绍了如何在Kohana 3.2中为此目录结构创建Route:/ application / my_use_case / classes /的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Kohana 3.2,我需要为我的应用程序创建下面的目录结构。为此,我使用下面的路线,但我做错了。 设置是我正在开发的用例。

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

?>

所以,这是我的设置用例的目录结构:

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

这是我的控制器的代码:

  class Controller_Settings extends Controller {

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

这是我使用的网址访问我的控制器:

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



谢谢,
Cheers

解决方案

由于您将目录设置为默认设置,因此您需要将控制器设置置于Settings目录中,而不是像下面这样:



路径



正确:application / classes / settings / settings.php



格式:apppath / classes /< directory> /< controller> .php

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


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

解决方案

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';
   }
}

这篇关于如何在Kohana 3.2中为此目录结构创建Route:/ application / my_use_case / classes /的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆