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 example

Hi,

I am totally newbie at Phalcon. Can someone show me an Dependency injection example when, for example, some model instance is injected into controller? I was trying to do this by examples all evening, but I failed. :((

Very thanks!

P. S. And please, type a files names above examples codes. :) It would be very helpful to understand easier, which file is controller, which is model, which is service.



58.4k

Hey

Big question, but you can see example service.php vokuro , in which author set some service mail, auth... you can use any where in project Phalcon

Hi,

Thanks. I tried on Vokuro project and everything works but then I try to create class into Invo example (official Phalcon example) and inject that class into controller, it doesn't work. I don't know why. :/



58.4k

you set dependency injection in file service yet ?