Question

I try to migrate application from version 1.11.2 to 1.12.1. I simply replaced Zend folder which contains 1.11.2 with Zend folder which contains 1.12.1. Application that worked in 1.11.2 doesn't work in 1.12.1, it can't load classes:

Fatal error: Class 'Plugin_AccessCheck' not found in 
C:\git_reps\mailable\application\Bootstrap.php on line 32

I have file with plugin in application/plugin folder and it worked in 1.11.2. Could you please tell me why my application doesn't work in 1.12.1 and how to make application work in new version? If I turn off plugin, it can't find other classes for example my models.

Here is fragmenet from application.ini:

resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
resources.view.doctype = "HTML5"

phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

autoloaderNamespaces[] = "Common_"
autoloaderNamespaces[] = "Shanty_"
resources.view.helperPath.Common_View_Helper_ = "Common/View/Helper/"


bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"

appnamespace = ""

resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0

Here code to register pluging:

/**
 * Init plugins
 */
protected function _initPlugins()
{
    $fc = Zend_Controller_Front::getInstance();     
    $applicationPart = getenv('APPLICATION_ENV_PART');      
    switch($applicationPart) {
        case 'subscribe':
            $fc->registerPlugin(new Plugin_SubscribeAccessCheck());
            return;             
            break;
        default:
            $fc->registerPlugin(new Plugin_AccessCheck());              
            break;      
    }   
}

When I turn off plugin in BootStrap, it can't find other files for example models.

Was it helpful?

Solution

If the suggest of @Marc not work try add the following line in application.ini:

resources.frontController.plugins.accessCheck = Plugin_AccessCheck

in Bootstrap.php:

/**
 * @return Zend_Application_Module_Autoloader
 */
protected function _initAutoload()
{
    $autoloader = new Zend_Application_Module_Autoloader(array('namespace' => '', 'basePath' => APPLICATION_PATH));
    $autoloader->addResourceType('plugin', 'plugins', 'Plugin');
    return $autoloader;
}

This works if the file is in the following path: /app/application/plugins/AccessCheck.php

OTHER TIPS

From the error, php can't auto load the class Plugin_AccessCheck, I'm guessing you have a Plugin directory in your lib folder with a php file called AccessCheck.php

Try adding

autoloaderNamespaces[] = "Plugin_"

to your application.ini or manually do an include for that file

If this isn't the case, you have mis-named your class Plugin_AccessCheck. possible solutions are moving it to your common lib Common/Plugin/AccessCheck.php and renaming the class to Common_Plugin_AccessCheck

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top