S
S
serjioms2015-03-02 15:50:21
PHP
serjioms, 2015-03-02 15:50:21

php. How to pass api kosher?

I am working on implementing some API using php. My question arose in how it is more correct (for example, from the point of view of most frameworks) to pass parameters.
In T.Z. I now have it like this:

method GET,  <sitename>/api?users <--получить всех юзереов;
method GET,  <sitename>/api?groups <--получить все группы;
method GET,  <sitename>/api?file <--получить file;
method GET,  <sitename>/api?filerem <--delete file;
method GET,  <sitename>/api?fileinfo <--return file info;
method GET,  <sitename>/api?groupsANDusers <--return groups and users;
method GET,  <sitename>/api?tymeStamp <--get user documents after that time;
...
method POST,  <sitename>/api?user <--createNewUser;
method POST,  <sitename>/api?group <--add new group;
method POST,  <sitename>/api?file <--upload file;
...

I see a solution to use switch case. But mvc tells me that if the request looked like this:
<sitename>/api/post/group/2;
<sitename>/api/get/documentInfo/id/123123123;

It would be easier for me to scatter with this. I would simply create a controller by name (having previously found out whether such a file exists, if not, I would pass it to ErrController) and pass parameters with values ​​there. Those. it would be just roughly 3 lines. And to add a new API method, one would simply need to create a controller file.
Or have I missed something, and is it possible to implement the GET parameter in the same way? Interested in the opinions of php developers who have worked with mvc and / or frameworks.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
FanatPHP, 2015-03-02
@serjioms

Or have I missed something, and is it possible to implement the GET parameter in the same way?

and what not?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question