We’re exploring the Restler framework. What we need is a custom route like:
[host]/:sessionid/{class}/{method}?param1=x¶m2=y
For example, the Settings method in the Game class:
<?php
class Game {
function settings($session, $sound=TRUE, $music=TRUE){
//
}
}
?>
should map to http://hostname/12435635/game/settings?sound=x&music=y
We’ve managed to achieve it by hacking the routes.php file a bit, but as the file is auto-generated the idea is not very good. So, is it possible to create such routes without hacking the Restler’s source or modifying the routes.php file?
First step is to remove class name from the URI. It can be achieved by modifying the
addAPIClassstatementthis changes the auto generated uri structure as follows
Next step is to specify a route manually by adding a PHPDoc comment to the api method as shown below
This will map to
This route will be added to
routes.phpevery time it is generated in production mode 🙂You may add more @url comments to create multiple routes to the same method