繁体   English   中英

Luracast Restler 3一无所获

[英]Luracast restler 3 returns nothing

我在安装Restler时搞砸了。 在我想要REST API的网站的子文件夹中,放入了restler附带的供应商目录(摆脱了所有其他内容),然后在同一级别创建了index.php文件:

<?php
require_once 'vendor/restler.php';
use Luracast\Restler\Restler;

$r = new Restler();
$r->addAPIClass('Test');
$r->handle();
?>

此级别的.htaccess文件只是Restler文档中的文件,没有任何更改。 然后,我创建了一个简单的Test.php文件,该文件仅返回JSON数组:

<?php
class Test {
    function index() {
        return [1, 2, 3];
    }
}
?>

现在查询该URL将返回nada:

curl -i https://.../dts/restler/Test
HTTP/1.1 200 OK
Date: Sun, 20 Jul 2014 18:20:40 GMT
Server: Apache/2.2.26 (Unix) DAV/2 PHP/5.4.24 mod_ssl/2.2.26 OpenSSL/0.9.8y
X-Powered-By: PHP/5.4.24
MS-Author-Via: DAV
Vary: User-Agent
Content-Length: 0
Content-Type: text/html; charset=UTF-8

请注意,“ X-Powered-By”仅仅是纯PHP吗? 如果我给的名字和测试的名字不同,我实际上会从Restler得到一个错误:

curl -i https://.../dts/restler/Invalid
HTTP/1.1 404 Not Found
Date: Sun, 20 Jul 2014 18:22:18 GMT
Server: Apache/2.2.26 (Unix) DAV/2 PHP/5.4.24 mod_ssl/2.2.26 OpenSSL/0.9.8y
X-Powered-By: Luracast Restler v3.0.0rc5
Vary: Accept,User-Agent
Cache-Control: no-cache, must-revalidate
Expires: 0
Content-Language: en
MS-Author-Via: DAV
Content-Length: 360
Content-Type: application/json; charset=utf-8

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

因此,我网站的根目录是... / dts,但我想在restler子目录中保存所有我喜欢的API东西,以保持环境整洁。

好吧,我只是想通了。 我必须将.htaccess移至网站的根目录,然后将RewriteRule更改为具有rester / index.php而不是index.php

暂无
暂无

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

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