I have created a plugins directory in the application directory.
Currently I am loading the plugins like so:
protected function _initAccessCheck()
{
include('../application/plugins/AccessCheck.php');
$fc = Zend_Controller_Front::getInstance();
$fc->registerPlugin( new Plugin_AccessCheck() );
}
What would I have to do so I would not have to use the include function? Many thanks in advance.
Zend_Loader_Autoloader_Resourceallows you to define a mapping between file paths and class names. This allows you to autoload classes whose files are not stored on the include path.Typically, you would use the subclass
Zend_Application_Module_Autoloaderwhich sets up some common mappings for models, forms, etc. In particular, it has an entry for plugins. In Bootstrap, it would be something like this:Then a class named
Application_Plugin_MyPluginwould reside in the fileapplication/plugins/MyPlugin.php.In your specific circumstance, it looks like you are using an empty namespace. So your’s would be:
Then your plugin class
Plugin_AccessCheckwould reside in the fileapplication/plugins/AccessCheck.php.Just make sure that the resource loader is created before you instantiate/register your plugins: