我正在尝试创建一个插件,用于为Oxwall框架创建API服务器。我是新来的餐厅,但有经验的开发人员为Oxwall平台。
当我访问url时,我会得到以下错误。
{
"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认为它对于比如说/*路由是有效的)
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() {
}
}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>发布于 2014-02-18 09:30:18
Say.php在index.php的同一文件夹中吗?否则,您应该在Say.php类中使用以下内容,例如,如果您的Say.php位于Say.php写中的Test/Say.php中
<?php
namespace Test;
use stdClass;
//..... the rest of your class在index.php中,您将编写
$r->addClass('Test\Say');behat.yml文件?base_url必须指向您的index.php路径
https://stackoverflow.com/questions/21813776
复制相似问题