如何在 Kohana 3.2 中为此目录结构创建路由:/application/my_use_case/classes/ [英] How can I create the Route in Kohana 3.2 for this directory structure: /application/my_use_case/classes/
问题描述
我正在使用 Kohana 3.2,我需要为我的应用程序创建下面的目录结构.为此,我正在使用下面的路线,但我做错了什么.设置"是我正在开发的用例.
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:
- ..applicationsettingsclassescontrollersettings.php
- ..applicationsettingsclassesmodelsettings.php
- ..applicationsettingsviewssettings_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
谢谢,干杯
推荐答案
由于您将目录设置为默认设置,因此您需要像这样将您的控制器设置放在设置目录中,而不是您这样做的方式:
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:
路径
正确:application/classes/settings/settings.php
Correct: application/classes/settings/settings.php
格式:apppath/classes/<目录>/<控制器>.php
Format: apppath/classes/<directory>/<controller>.php
Class Controller_Settings_Settings extends Controller {
public function action_index(){
echo 'test';
}
}
这篇关于如何在 Kohana 3.2 中为此目录结构创建路由:/application/my_use_case/classes/的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!