php造成404,php – Restler总是返回404:未找到

我在本地服务器上安装了Restler来测试并为我的项目制作一些API.

Api请求通过http:// localhost / myproject / api /处理.

问题是每次我尝试发出请求时都会收到以下错误:

{

"error": {

"code": 404,

"message": "Not Found"

},

"debug": {

"source": "Routes.php:383 at route stage",

"stages": {

"success": [

"get"

],

"failure": [

"route",

"negotiate",

"message"

]

}

}

}

这也是我的.htaccess:

RewriteEngine on

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^api(.*)$/myproject/api/api.php [QSA,L]

这就是api.php的样子:

namespace myproject;

use Luracast\Restler\Restler;

require_once($_SERVER["DOCUMENT_ROOT"]."/myproject/resources/engine/settings.php");

require_once(Settings\Path\Absolute::$library."/restler/vendor/restler.php");

$restler = new Restler();

$restler->addAPIClass("myproject\\User");

$restler->handle();

我猜周围有一些误配,但我真的无法弄清楚出了什么问题.

(我也在Stackoverflow上尝试了一些解决方案,但它们似乎对我不起作用)

编辑:

我尝试使用以下路径http:// localhost / myproject / resources / engine / library / restler / public / examples来实现示例,并且它们正在工作,所以我想它与Restler本身的配置有关,因为它没有似乎在http:// localhost / myproject / api中工作.

此外我还尝试在http:// localhost / myproject / api / explorer中复制Restler Explorer并且我一直收到错误:404:Not Found ../resources.json可能是因为我没有在根文件夹中安装Restler我的项目.我怎么能在不同的子文件夹中安装Restler?

编辑2:

我刚刚将以下类移到示例001文件夹中:

class User {

function data() {

return "HELLO!";

}

}

并在示例的index.php中添加了这一行:

$r->addAPIClass('User');

如果我试图在… / _ 001_helloworld / index.php / say / hello运行示例它没有问题,但如果我尝试_001_helloworld / index.php / user / data则不行.

在这一点上,我已经失去了所有的希望,我真的需要帮助’因为我真的错过了什么,但实在无法猜到:(帮助!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值