首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >404 Error with Restler for all Url

404 Error with Restler for all Url
EN

Stack Overflow用户
提问于 2014-02-16 16:13:05
回答 1查看 935关注 0票数 3

我正在尝试创建一个插件,用于为Oxwall框架创建API服务器。我是新来的餐厅,但有经验的开发人员为Oxwall平台。

当我访问url时,我会得到以下错误。

代码语言:javascript
复制
{
  "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认为它对于比如说/*路由是有效的)

代码语言:javascript
复制
OW::getRouter()->addRoute(new OW_Route('service', 'say/:cmd', "OXWALLAPI_CTRL_Api", 'index'));

所以现在,当我尝试访问http://www.mysite.com/say/hello时,它会得到上面的404错误。

api.php :

代码语言:javascript
复制
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:

代码语言:javascript
复制
class Say {

    function hello($to = 'world') {
       return "Hello $to!";
    }

    function hi($to) {
       return "Hi $to!";
    }

}

Oxwall有自己的.htaccess文件。我已经将下面的.htaccess放在插件文件夹中。

代码语言:javascript
复制
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>
EN

回答 1

Stack Overflow用户

发布于 2014-02-18 09:30:18

  • Say.phpindex.php的同一文件夹中吗?

否则,您应该在Say.php类中使用以下内容,例如,如果您的Say.php位于Say.php写中的Test/Say.php中

代码语言:javascript
复制
<?php
namespace Test;
use stdClass;
//..... the rest of your class

在index.php中,您将编写

代码语言:javascript
复制
$r->addClass('Test\Say');
  • 您是否正确地设置了behat.yml文件?

base_url必须指向您的index.php路径

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21813776

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档