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

Get access to DI inside static methods

What is the best way to get static methods to access the dependency injector?



98.9k

You can use the method Phalcon\DI::getDefault() to get the latest DI created in an static way.

https://docs.phalcon.io/en/latest/reference/di.html#accessing-the-di-in-a-static-way

Sorry! Missed it while reading the docs!