【发布时间】:2013-12-01 12:03:32
【问题描述】:
我刚刚开始使用 Restler 创建一个 api 并拥有以下代码。
index.php
require_once '../vendor/restler.php';
use Luracast\Restler\Defaults;
use Luracast\Restler\Restler;
Defaults::$useUrlBasedVersioning = true;
$r = new Restler();
$r->setAPIVersion(1);
$r->setSupportedFormats('XmlFormat', 'JsonFormat');
$r->addAPIClass('Info', '');
$r->addAPIClass('Info');
$r->addAPIClass('getList');
$r->handle();
info.php
<?php
class Info {
function index() {
return "Version 1.0.0";
}
}
?>
v1/getList.php
<?php
namespace v1;
use stdClass;
class getList
{
function index()
{
return "hello";
}
function newest() {
return "hello2";
}
}
我正在 Windows 机器上使用 xampp 对其进行测试,并且 localhost/api/ 已映射到公用文件夹。 当我在浏览器中打开 localhost/api/ 时,它将按预期显示 Version 1.0。但是当我打开 info 或 getList 时,我从 apache 收到 404 错误。
我该如何解决? 非常感谢您的帮助
【问题讨论】: