Zend Framework 1.11 - Registering plugins in Application.ini or Bootstrap.php?

I have reviewed various sites for Zend Framework best practices and information and understand that you can register plugins in two ways:

Application.ini

resources.frontController.plugins.PluginName = "App_Controller_Plugin_PluginName" 

and...

Bootstrap.php

 $frontController->registerPlugin(new My_Controller_Plugin_ModuleLayout()); 

My question is what is the best / preferred method and why?

+4
source share
3 answers

My personal opinion is that doing this in bootstrap is a little better. One example scenario is if you have a custom plugin, you can invoke the constructor with some choices (which can be objects - with application.ini you cannot do this).

But, as I said, this is only my preference, I would also like to know if there are any best practices, so +1 for the question :)

+1
source

Think of it this way.
When you configure the application using Zend_Tool (ZF.bat).
Zend provides you with basically a complete application.ini and empty Bootstrap.php.
I am sure that in most cases, registering plugins in application.ini will be considered acceptable, if not best practice.
Some plugins will always work better or easier with bootstrapping.
In the end, it comes down to: Do what is best for you and your project!

0
source

One of the advantages of using the Bootstrap method is the flexibility to register certain modules with modules. With Application.ini, your settings apply to your entire application. If you have a fairly large application with two plugins, you won’t want them to be executed every time a part of your application is requested.

I agree that Application.ini is a little easier to register and de-register, and for a different environment

0
source

Source: https://habr.com/ru/post/1393745/


All Articles