We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Is there way to access HTTP PUT-parameters with \Phalcon framework?

Hello.

We want to implement full REST in our application (this is means we want to enable "PUT" and "DELETE" queries in the API).

There is one trouble with "PUT"-query parameters: Payload parameters of HTTP-PUT-request does not exists In the $_GLOABALS. So we can't access them through $this->request->get() ($this->request is \Phalcon\Http\Request).

But if we read 'php://input' we can see all passed "PUT"-parameters. Is there way to access parameters with \Phalcon framework or we need to parse "manually" every "PUT"-request?



39.3k
Accepted
answer

To my knowledge the Request object does not handle those. In a similar project as yours I had to rely on php://input to give me the functionality I wanted when issuing a PUT.



36.0k

Thank you. We do the same now.

There is interesting feature: If we set $_GLOBALS["_PUT"] manually then $this->request->get() returns data from $_PUT array correctly :).

As of version 3 $this->request->getPut() should do the trick. Check doc

To my knowledge the Request object does not handle those. In a similar project as yours I had to rely on php://input to give me the functionality I wanted when issuing a PUT.