I’ve been trying to use the Restler php api.
I have an api.php file at the root of my webserver:
<?php
require_once('lib/restler.php');
class Say {
function hello($to='world') {
return "Hello $to!";
}
}
$r = new Restler();
$r->addAPIClass('Say');
$r->handle();
?>
I try with the simplest example GET api.php/say/hello, but nginx keep responding me with an error 404. And in the logs I see “Not a directory”.
I guess it’s a problem with my nginx conf, but can’t find any specific information about it. Any idea?
To solve my problem:
I put my code into /api/index.php
Then modified my nginx configuration to add:
So now if I call GET /api/say/hello, it redirects to /api/index.php/say/hello and the rewriting rules allow restler to do its magic.
I hope this will help future users of restler on nginx.