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

Dependency injection object is required

I have a strange error.

The code var_dump(array_keys($this->di->getServices()));

prints array(22) { ... [5]=> string(8) "response" ... }

The code var_dump($this->di->getServices()['response']);

prints object(Phalcon\DI\Service)#22 (4) { ["_name":protected]=> string(8) "response" ["_definition":protected]=> string(21) "Phalcon\Http\Response" ["_shared":protected]=> bool(true) ["_sharedInstance":protected]=> NULL }

But code $this->di->get('response'); Throws an error A dependency injection object is required to access the 'response' service

What can be wrong?

My mistake, sorry.