i have just started to create an api with Restler and have the follwoing code.
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";
}
}
I'm testing it with xampp on a windows machine and localhost/api/ is mapped to the public folder. When i open localhost/api/ in the browser it will show Version 1.0 as expected. But when i open info or getList i get a 404 error from apache.
How can i fix it? Many thanks for your help
You should add this to your
/api/.htaccess
file: