Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

A dependency injection object is required to access the 'filter' service

If I do as it is written in the documentation — https://docs.phalconphp.com/en/latest/api/Phalcon%5Http%5Request.html

use Phalcon\Mvc\Controller;
use Phalcon\Http\Request;

$request = new Request();
$name = $request->getPost("name", "email");

And I get an error: A dependency injection object is required to access the 'filter' service

But If I do so:

use Phalcon\Mvc\Controller;

$name = $this->request->getPost("name", "string");
$phone = $this->request->getPost("phone", "string");

All OK.



12.6k
Accepted
answer

in the api documentation you get an example of how you can implement the request in bootstrap and then in controller you call it from DI. If you're going to do new Request() in each action, of course you'll get an empty request all the time.