I studied the API and developed the REST API for the project we are working on.
The API only accepts connections from a single source in JSON format, I understand that this is a bit.
If you understand most of the above, however, I donβt understand the third code example and where routing information will be displayed.
An example they provided:
$data = RestUtils::processRequest(); switch($data->getMethod) { case 'get': // retrieve a list of users break; case 'post': $user = new User(); $user->setFirstName($data->getData()->first_name); // just for example, this should be done cleaner // and so on... $user->save(); break; // etc, etc, etc... }
The part I'm not sure about is how to accept the original ie / get / user / 1 request - how you redirect this to the correct part of the script.
If there was another SO question (I searched quite a bit of time) or any additional educational examples, please point me in the right direction.
Update
I found several PHP classes for routing, but nothing that just does a little and does what it says in tins, everything seems to do routing + 2000 other things on top.
Now I have all the classes that I need for this project, since I want to access them from the ie URI:
/ data / users / data / users / 1 / hash / users / hash / users / 1 / put / users / 1? JSON = {data}
Thus, they should all use the users class, then one of the data, hash or put methods then passes something extra after that to the method as arguments.
If anyone could just explain how this bit works, that would be a huge help!
Thanks:)