【发布时间】:2014-02-16 16:13:05
【问题描述】:
我正在尝试创建一个插件来为 Oxwall 框架制作 API 服务器。我是 Restler 的新手,但在 Oxwall 平台方面经验丰富。
访问网址时出现以下错误。
{
"error": {
"code": 404,
"message": "Not Found"
},
"debug": {
"source": "Routes.php:383 at route stage",
"stages": {
"success": [
"get"
],
"failure": [
"route",
"negotiate",
"message"
]
}
}
}
Oxwall 有自己的路由和 MVC 方法。下面是我定义路由的方式(cmd 只是一个虚拟值,让 Oxwall 认为它对 say/* 路由有效)
OW::getRouter()->addRoute(new OW_Route('service', 'say/:cmd', "OXWALLAPI_CTRL_Api", 'index'));
所以现在,当我尝试访问 http://www.mysite.com/say/hello 时,会出现上述 404 错误。
api.php:
use Luracast\Restler\Restler;
class OXWALLAPI_CTRL_Api extends OW_ActionController {
public function __construct() {
parent::__construct();
$r = new Restler();
$r->addAPIClass('Say');
$r->handle();
}
public function index() {
}
}
说.php:
class Say {
function hello($to = 'world') {
return "Hello $to!";
}
function hi($to) {
return "Hi $to!";
}
}
Oxwall 有自己的 .htaccess 文件。我已将以下 .htaccess 放在插件文件夹中。
Options -MultiViews
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^$ index.php [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
<IfModule mod_php5.c>
php_flag display_errors Off
</IfModule>
【问题讨论】: