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

How do you register a plugin? (for multi modules)

I want to share a beforeExecuteRoute for all the routes of my multi module app.

For that I wanted to have a plugin shared by all my modules which will be attached to 'dispatch' using the event manager. What I don't get is how I can register the plugin dir, just once. I found examples for single module app.



2.1k

create a loader.php in the same level as apps folder, and place the loading code there, and include that file in the bootstrap



2.8k

That loader will contain my plugin?

create a loader.php in the same level as apps folder, and place the loading code there, and include that file in the bootstrap



3.3k
Accepted
answer

no the loader will register your custom mades plugins and instantiate to the services or in your bootstrap file



2.8k

Thx it worked.

For the ones wondering, by loader they meant \Phalcon\Loader().

no the loader will register your custom mades plugins and instantiate to the services or in your bootstrap file