I've messed something up on my installation of restler. Down in a subfolder of my website where I want the REST api I put the vendor directory that comes with restler (got rid of everything else), and then I created an index.php file at that same level:
<?php
require_once 'vendor/restler.php';
use Luracast\Restler\Restler;
$r = new Restler();
$r->addAPIClass('Test');
$r->handle();
?>
The .htaccess file at this level is just the one from the Restler documentation without change. Then I created a simple Test.php file that just returns a JSON array:
<?php
class Test {
function index() {
return [1, 2, 3];
}
}
?>
Querying that URL now returns 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
Notice how the "X-Powered-By" is just plain PHP? If I give a different name than test, I actually get an error from 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"
]
}
}
}
So the root of my site is .../dts, but I want to have all my restful API stuff in the restler subdirectory to keep things clean.
OK, I just figured this out. I had to move the .htaccess to the root of the website and then changed the RewriteRule to have rester/index.php instead of just index.php