When i started writing a REST service on Kebab Project, I recognized that we can’t access the imcoming data at PUT and DELETE method with $POST or $GET. It was really suprised me. So how can php access the incoming data. I searched on internet and i found php://input is the solution.
1
| |
The above line provided us with a query string. It is similar to GET Request on the URL. If you parse this query string, you can access the incoming params.
1 2 | |
You can find more information at LornaJane blogs over this issue.
But usually we use php framework and we wanna the general solutions over this issue. We use Zend Framework at Kebab Project. All Kebab Project Services are RestFull so we need a good solutions over this issue. I found good article on the weblog and site of Matthew Weier O’Phinney. His helper is very neat and very usefull. Then i wrote our helper which only support JSON response type.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | |
When you look the init function you can understand the tips. How you can use the Param Helpers at and Controller. You set a variable with this helper.
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
I wish this little article help the people who use Kebab Project and develop restfull software with Php.
Best Regards.