-
-
Notifications
You must be signed in to change notification settings - Fork 315
A FAQ will be created here. Please give us some time to fill it.
If you have any questions in the meantime plesae go to the Issues part and ask your question.
Q. How do i map functions to calls?
A. You can do this in 2 different ways:
- Mapping with function names:
<?php
class classname {
function get() {
/* This function maps to GET /classname */
}
function getFunction()
/* This functions maps to GET /classname/Function */
}
}
?>
This counts for all methods ( get,post,put & delete )
- Use phpdoc comments for the routing:
<?php
class classname {
/*
* @url GET /
*/
function SomeFunctionName() {
/* this function is being mapped to GET /classname */
}
/*
* @url GET /Somethingelse
*/
function AnOtherFunction() {
/* This function is being mapped to GET /classname/Somethingelse */
}
}
?>
Again this counts for all methods.
Q. Can i create different custom routes to 1 function.
A. Yes you can. Here is an example:
<?php
class test {
/**
* @url GET /test
* @url GET /another/test
* @url DELETE /test
*/
function customfunction() {
}
}
?>
Q. What does CRUD mean?
A.
CRUD stands for Create Read Update Delete.
You can map this to HTTP verbs as: Post Get Put Delete.
These HTTP verbs are used in the HTTP requests.
Q. How do i execute a DELETE command.
A.
You will need to give the identifier in the url instead of in the body.
For example:
DELETE http://help.luracast.com/restler/examples/_006_crud/index.php/author/2
or
DELETE http://help.luracast.com/restler/examples/_006_crud/index.php/author?id=2
Q. Which formats are currently supported?
A. Currently the following formats are supported:
- xml
- json
- plist ( xml and binary )
- amf
- yaml
Q. How do I tell the API to give me the output in a certain format?
A. There are 2 options you can do this.
- Use the header "HTTP_ACCEPT" field you can specify what kind of content you except.
- Put the extension in the end of the url http://host.com/api/helloworld.json
Q. My client doesn't support PUT or DELETE statements. How can i override this?
A. You can set the header "HTTP_X_HTTP_METHOD_OVERRIDE" with the POST, GET, PUT or DELETE statement.
Q. I have production mode enabled and changed something to the routing but it doesn't work?
A. In production mode RESTLER creates a routes.php cache file where all the routes are defined. This is done to avoid recreating the routes on the fly with every request. If you want to recreate the routes.php cache file, simply delete it or call the php function: refreshCache()
Q. I need an other output format. How do i implement that?
A. Please check the code and search for 'iFormat'. This interface defines the functions that are being used. You can look at the json code for tips.