Zend autoloader not working on live site
I've just copied my dev site to the live server, updated configs with new DB connection details etc, but get the following error message:
Fatal error: Uncaught exception 'Zend_Loader_PluginLoader_Exception' with message `'Plugin by name 'IncludeStyles' was not found in the registry; used paths: Zend_View_Helper_Navigation_: Zend/View/Helper/Navigation/ Zend_View_Helper_: Zend/View/Helper/:./views/helpers/:/home/wheresrh/public_html/spz/application/views/helpers/' in /home/wheresrh/public_html/spz/library/Zend/Loader/PluginLoader.php:412 Stack trace: #0 /home/wheresrh/public_html/spz/library/Zend/View/Abstract.php(1173): Zend_Loader_PluginLoader->load('IncludeStyles') #1 /home/wheresrh/public_html/spz/library/Zend/View/Abstract.php(609): Zend_View_Abstract->_getPlugin('helper', 'includeStyles') #2 /home/wheresrh/public_html/spz/library/Zend/View/Abstract.php(336): Zend_View_Abstract->getHelper('includeStyles') #3 [internal function]: Zend_View_Abstract->__call('includeStyles', Array) #4 /home/wheresrh/public_html/spz/application/layouts/layout.phtml(19): Zend_View->includeStyles('full') #5 /home/wheresrh/public_html/spz/library/Zend/View.php(108): include('/h in /home/wheresrh/public_html/spz/library/Zend/Loader/PluginLoader.php on line 412`
So it looks like the autoloader is failing to pick up the views/helpers directory as the location for helper classes, even though the folder structure and bootstrap are exactly the same on the live and development sites.
What else could be affecting the autoloader's ability to find the helper classes?
Here's my application.ini:
[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
autoloaderNamespaces[] = "SPZ_"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
resources.layout.layoutPath = APPLICATION_PATH "/layouts/"
resources.db.adapter = PDO_MySql
resources.db.params.host = localhost
resources.db.params.username = ******
resources.db.params.password = ******
resources.db.params.dbname = ******
And my bootstrap
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initAutoload()
{
$moduleLoader = new Zend_Application_Module_Autoloader(array(
'namespace' => '',
'basePath' => APPLICATION_PATH));
}
protected function _initViewHelpers()
{
$this->bootstrap('layout');
$layout = $this->getResource('layout');
$view = $layout->getView();
$view->doctype('XHTML1_STRICT');
$view->headMeta()->appendHttpEquiv('Content-Type', 'text/html;charset=utf-8'开发者_高级运维);
$view->headTitle()->setSeparator(' - ');
$view->headTitle('Sum Puzzles');
$view->addHelperPath(APPLICATION_PATH.'/views/helpers/');
}
}
And here is my index.php
<?php
error_reporting(E_ALL | E_STRICT);
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()
->run();
Maybe I have some conflicting/redundant lines in my bootstrap and config files?
*edit I'm now trying to copy to a differenet server and getting similar errors as the "views" directory has not been set as teh place to look for view scripts.
Adding another answer as it takes a totally different tack.
In my experience, success on one platform (like a local WinXP dev machine) followed by a failure on my production machine (like a Linux box) is the result case-sensitivity in a file name or a class name. Windows lets it slide since the paths in the filesystem are case-insensitive, while Linux calls me out for my carelessness.
In your case, es posible?
For example, the stack trace mentions a folder /home/wheresrh/public_html/spz/
, but the configs/application.ini
adds an autoloaderNamespace[] = "SPZ_"
It turns out that there was something wrong with my ftp client so some files were uploaded incomplete. A fresh upload fixed this. Just my luck to work this out AFTER offering a bounty.
Isn't there a conflict between between these values:
'SPZ_'
given in theappnamespace
directive inapplication/config.ini
""
, provided as the appnamespace inBootstrap::_initAutoloader()
Doesn't explain - at first glance - why you are observing a difference between development and production environments, but anything that affects the loading/autoloading seems likely to be relevant.
精彩评论