我正在尝试创建一个插件来为 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 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() {
}
}
Say.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>