Currently, the plugins I write seem to work or not randomly. Some of them work, some do not, and some of them work part time, again without an obvious picture. Even if they are all written and registered (apparently) the same way. And I cannot find the correct documentation on where to place your plugins and how to register them in application.ini, so I need to rely on the examples that I find on blogs or here. Probably some of these examples suggest things that might be wrong in my code.
So, I will just give a simple example, and if you could suggest how to make it work, and provide links to good articles about ZF plugins, I would really appreciate that ...
This is how I am doing it now:
Directory structure:
/library /Zend /Plugins Myplugin.php /applications /myApp /configs application.ini /modules /default /controllers /configs /views, etc /admin /controllers /configs /views, etc Bootstrap.php /public_html index.php
Myplugin.php contains one class:
Class Plugins_Myplugin extends Zend_Controller_Plugin_Abstract { public function init() { print 'If I can see this, it finally working!'; } }
The relevant application.ini material is as follows:
includePaths.library = APPLICATION_PATH "/../../library" bootstrap.path = APPLICATION_PATH "/Bootstrap.php" pluginpaths.plugins = "Plugins" resources.myplugin = resources.frontController.plugins.myplugin = Plugins_Myplugin ;//I assume Plugins_Myplugin should be resolved into library/Plugins/Myplugin.php with class Plugins_Myplugin inside, given present configuration. Most likely I am wrong somewhere
And the most common mistake is usually this:
Fatal error: class 'Plugins_Myplugin' not found in /whatever/nevermind/domains/mydomain/library/Zend/Application/Resource/Frontcontroller.php on line 117
Sometimes this can be found if I "register" it only with the resources .myplugin =, omitting the whole * resources.frontController.plugins.myplugin = Plugins_Myplugin *.
So, apparently, this is the wrong way to register your plugins. What is wrong with this, and what would be a good way (using application.ini)?