phpzend-frameworkzend-autoloader

application that works in Zend 1.11.2 doesn't work in 1.12.1


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.


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