-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapi-howto
20 lines (16 loc) · 1 KB
/
api-howto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
API howto's
If you want to build a new API you can do so by creating a new class under api/v1. (ProfileEndpoint.php is a good base to start with)
Each API class can have multiple methods (GET, POST, ...)
the code you wish to execute in the get method should go in the method function handleGetRequest(), for the post method function handlePostRequest()
Each endpoint that you define should extends RestServiceBaseEndpoint
this baseclass validates the headers and delegates the request to the correct method of your endpoint.
URLS
To map a URL to a php endpoint we use the .htaccess file in /api/v1
Add an entry there if you build a new endpoint.
API documentation
To add an api to the documnetation document your endpoint class with the correct annotations.
Then open the file apidoc.php and do following steps:
1. require_once 'path-to-your-file/file.php'
2. add an entry in the classes array
Afterwards run the file to generate the docs like this: php apidoc.php.
This will generate the html under the defined folder.