簡體   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