/api is a special automatically routed url.
back > sys > api.php
The API endpoint in the PAX framework is setup to automate POST and GET access to an application without having to write any wrapper / controller classes and then returning a JSON object. It also can handle post requests,
where the return URL can be set in the return object from the method.
(Example: return ['success'=>1,'url'=>'/account/thankyou'];)
1. By default this route will not include any template files.
2. This url provides immediate access to class methods specified in the url /api/class_name/method_name
3. By default the $_URL and $_POST variables are passed to the method being called.
Name | Description |
---|---|
http://yourwebsite.com/api/class/method?pretty=1 | Returns a pretty print JSON object |
http://yourwebsite.com/api/class/method?post=1 | Forces a POST request to a class->method. |
back > app > modelExample.php
class modelExample {
public function method($url=[],$post=[]){
print_r([$url,$post]);
}
}
POST http://website.com/api/modelExample/method/var1/var2
//prints out returned object from $app->modelExample->method in JSON format
{
[
"var1",
"var2"
],
{
"name":"Name",
"email":"test@test.com"
}
}