简体   繁体   English

404所有Url的Restler错误

[英]404 Error with Restler for all Url

I am trying to create a plugin for making an API server for Oxwall framework. 我正在尝试为Oxwall框架创建一个用于制作API服务器的插件。 I am new to Restler but experienced developer for Oxwall platform. 我是Restler的新手,但他是Oxwall平台的开发人员。

I get the below error when I access the url. 我访问网址时收到以下错误。

{
  "error": {
    "code": 404,
    "message": "Not Found"
  },
  "debug": {
    "source": "Routes.php:383 at route stage",
    "stages": {
      "success": [
        "get"
      ],
      "failure": [
        "route",
        "negotiate",
        "message"
      ]
    }
  }
}

Oxwall has its own Routing and MVC methods. Oxwall有自己的路由和MVC方法。 Below is how I have defined the route (cmd is just a dummy value to make Oxwall consider it valid for say/* routes) 下面是我如何定义路线(cmd只是一个虚拟值,使Oxwall认为它对于说/ *路线有效)

OW::getRouter()->addRoute(new OW_Route('service', 'say/:cmd', "OXWALLAPI_CTRL_Api", 'index'));

So now, when I try to access http://www.mysite.com/say/hello it get the above 404 error. 所以现在,当我尝试访问http://www.mysite.com/say/hello时,它会收到上述404错误。

api.php : 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: Say.php:

class Say {

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

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

}

Oxwall has its own .htaccess file. Oxwall有自己的.htaccess文件。 I have placed the below .htaccess in the plugin folder. 我已将下面的.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>
  • Is Say.php in the same folder of index.php ? Say.phpindex.php的同一个文件夹中吗?

Otherwise you should use the following in Say.php class, if for instance your Say.php is in Test/Say.php In Say.php write 否则你应该在Say.php类中使用以下内容,例如你的Say.php是在Test / Say.php中的Say.php写的

<?php
namespace Test;
use stdClass;
//..... the rest of your class

In index.php you'll write 在index.php中你会写

$r->addClass('Test\Say');
  • Did you properly set the behat.yml file? 你有没有正确设置behat.yml文件?

base_url must point to your index.php path base_url必须指向index.php路径

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM