This may be a bit of a noob question, but I'm having difficulty figuring out
how to autoload/call a class that's in the library of my directory
structure. The directory structure is as follows:
- application
- configs
- modules
- auth
- controllers
- ...
- Bootstrap.php
- default
- guestbook
- Bootstrap.php
- library
- portalClasses
- models
- DbBaseTable.php
- Zend
- public
- index.php
In the index.php file I set up all the base include paths I need:
$includePaths = array(
APPLICATION_PATH . '/../library',
APPLICATION_PATH . '/../library/portalClasses/models',
APPLICATION_PATH . '/modules/default/controllers',
APPLICATION_PATH . '/modules/default/models',
APPLICATION_PATH . '/modules/guestbook/controllers',
APPLICATION_PATH . '/modules/guestbook/models',
APPLICATION_PATH . '/modules/authroization/controllers',
APPLICATION_PATH . '/modules/authroization/models',
get_include_path());
set_include_path(implode(PATH_SEPARATOR, $includePaths));
And in the primary Bootstrap.php file I've instatiated the autoloader:
protected function _initAutoload()
{
$autoloader = new Zend_Application_Module_Autoloader(array(
'namespace' => 'portalLib_',
'basePath' => APPLICATION_PATH .
'/../library/portalClasses',
));
return $autoloader;
}
I have a few abstract classes that my module model classes extend which
defines the correct database adapter to use for each model class which I
have put in /library/portalClasses/models. For example:
[DbBaseTable.php]
abstract class portalLib_Model_DbBaseTable_Abstract extends
Zend_Db_Table_Abstract{
public function __construct ($config = null)
{
if (isset($this->_use_adapter)) {
// $config = Zend_Registry::get($this->_use_adapter);
$bootstrap = $this->getInvokeArg('bootstrap');
$resource = $bootstrap->getPluginResource('multidb');
$this->accessDb = $resource->getDb('access_data');
$this->appDb = $resource->getDb();
}
return parent::__construct($config);
}
}
And I extend this class with various module models, for example in the
/application/modules/auth/models folder:
[Users.php]
class Auth_Model_Users extends portalLib_Model_DbBaseTable_Abstract
{
protected $_name = 'access_data.users';
protected $_primary = 'user_id';
...
}
...which throws a 'Class 'portalLib_Model_DbBaseTable_Abstract' not found'
error. I've explicitly included the 'DbBaseTable.php' file and it works
fine. Any clues as to where I'm going wrong with the autoloading and/or
routing? Thanks for any help!
--
View this message in context:
http://zend-framework-community.634137.n4.nabble.com/Autoloading-and-routing-question-tp2076084p2076084.html
Sent from the Zend Framework mailing list archive at Nabble.com.