#Installation Steps
You can find the mysql import sql file in the docs folder (deezer.sql)
Configure database setting in the file /database/config.php
I used PHP PDO so that any further changes of database can be done more quickly.
I used POSTMAN Chrome extension to test my API Calls
###List of available call for Users
/api/users/:id
/api/users/favorites/:id
/api/users/favorites/:user_id/:song_id
/api/users/favorites/:user_id/:song_id
###List of available call for Songs
/api/songs/:id
#Architecture guidelines
AbstractAPI contains all the basic stuff of an API. It analyses the Request and calls the method which has the same name. Example : /api/user ==> BaseAPI will try to call a function named user().
There is also the possibility to define a specific action for the endpoint. Example : /api/user/favorite
Therefore, a specific behavior can be implemented in the user() function by analysing the end point action (if not null)
So basically we have : /api/{end point}/{optionnal end point action}/{arg1}/{arg2}....
DeezerAPI is a child of BaseAPI and provides all necessary endpoints functions such as
- users()
- songs()
- ... to be implemented
You only have to create your own functions to handle new API calls In each one, GET, POST, PUT, DELETE are matched. There are also specific conditions for the end point actions.
DeezerAPI returns a JSONResponse object, so all responses are similar. Example : /api/users/1 (GET)
{ "status": "success", "data": { "user": { "id": "1", "name": "michel", "email": "michel.parreno@gmail.com" } }, "message": null }
Autoloading is handled by namespaces. Don't forget to add the "use ..." statements to properly load all necessary classes.
#What I would have used normally
- Teamwork !!
- Symfony Framework
- Swagger
- Nelmio apidoc bundle