If you create a Bootstrap.php file in the module directory with class
Module_Boostrap extends Zend_Application_Module_Bootstrap your models are
available at Module_Model_YourModel.
You will have to set modules.[] in your application.ini to work with that setup.
I hope that answers your question..
Am 07.04.2010 um 20:17 schrieb benxmy [via Zend Framework Community]:
> Hi,
> I'm currently building a portal that will have a growing number of modules
> running through this single portal and I've failed to completely figure out
> how to get it all running. I've plowed through dozens of different posts and
> threads about this, but can't quite wrap my head around what part I'm
> missing. Any insight would be greatly appreciated!
> My current directory structure is:
>
>
> - application
> - configs
> - application.ini
> - modules
> - default
> - ...
> - guestbook
> - controllers
> - IndexController.php
> - GuestbookController.php
> - models
> - Guestbook.php
> - GuestbookMapper.php
> - ...
> - Bootstrap.php
> - library
> - ZendFramework
> - public
> - index.php
>
>
> The application.ini file is:
> [production]
> phpSettings.display_startup_errors = 0
> phpSettings.display_errors = 0
> includePaths.library = APPLICATION_PATH "/../library"
> bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
> bootstrap.class = "Bootstrap"
> appnamespace = "Application"
> resources.frontController.params.displayExceptions = 0
> resources.layout.layoutPath = APPLICATION_PATH
> "/modules/guestbook/layouts/scripts"
> resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
> resources.view[] =
>
> My current index.php file is:
>
> // 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') : 'development'));
>
> $includePaths = array(
> APPLICATION_PATH . '/../library',
> APPLICATION_PATH .
> '/modules/default/controllers',
> APPLICATION_PATH . '/modules/default/models',
> APPLICATION_PATH .
> '/modules/guestbook/controllers',
> APPLICATION_PATH .
> '/modules/guestbook/models',
> get_include_path());
>
> set_include_path(implode(PATH_SEPARATOR, $includePaths));
>
> /** Zend_Application */
> require_once 'ZendFramework/library/Zend/Application.php';
>
> // Create application, bootstrap, and run
> $application = new Zend_Application(
> APPLICATION_ENV,
> APPLICATION_PATH . '/configs/application.ini'
> );
>
> $controllerArray = array(
> 'default' => APPLICATION_PATH .
> '/modules/default/controllers',
> 'guestbook' => APPLICATION_PATH .
> '/modules/guestbook/controllers');
>
> $front = Zend_Controller_Front::getInstance();
>
> $front->setControllerDirectory($controllerArray);
>
> $front->addModuleDirectory(APPLICATION_PATH . '/modules');
>
> $application->bootstrap()
> ->run();
>
> Currently, my Bootstrap.php file is empty:
>
> class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
> {
> }
>
>
> If I pull up the base url (http://rebuild.local), it pulls up the default
> index controller, as expected. If i go to http://rebuild.local/guestbook, it
> routes to the guestbook module IndexController (I just have a placeholder
> here):
>
> class Guestbook_IndexController extends Zend_Controller_Action
> {
> public function init() {
> /* Initialize action controller here */
> }
>
> public function indexAction() {
> echo "Guestbook Index Controller";
> }
>
> public function guestbookAction() {
> }
> }
>
> However, when I try to pull up the GuestbookController
> (http://rebuild.local/guestbook/guestbook):
>
> class Guestbook_GuestbookController extends Zend_Controller_Action
> {
> public function indexAction() {
> $guestbook = new Modules_Guestbook_Model_GuestbookMapper();
> $this->view->entries = $guestbook->fetchAll();
> }
>
> public function signAction() {
> $request = $this->getRequest();
> $form = new Application_Form_Guestbook();
>
> if($this->getRequest()->isPost()) {
> if($form->isValid($request->getPost())) {
> $comment = new
> Application_Model_Guestbook($form->getValues());
> $mapper = new
> Application_Model_GuestbookMapper();
> $mapper->save($comment);
> return $this->_helper->redirector('index');
> }
> }
> $this->view->form = $form;
> }
> }
>
> I get the following error:
> Fatal error: Class 'Modules_Guestbook_Model_GuestbookMapper' not found in
> C:\Users\ben\Zend\workspaces\DefaultWorkspace\rebuild\application\modules\guestbook\controllers\GuestbookController.php
> on line 7
>
> GuestbookMapper.php (a model class):
>
> class Guestbook_Application_Guestbook_Model_GuestbookMapper
> {
> protected $_dbTable;
>
> public function setDbTable($dbTable) {
> if(is_string($dbTable)) {
> $dbTable = new $dbTable();
> }
> if(!$dbTable instanceof Zend_Db_Table_Abstract) {
> throw new Exception('Invalid table data gateway
> provided');
> }
> $this->_dbTable = $dbTable;
> return $this;
> }
> ....
> }
>
> I believe my limitation here is a misunderstanding of the routing and how the
> app is trying to find the GuestbookMapper class and possibly the naming
> scheme I should be using for the class itself, though I've played around with
> a number of different ways of fixing that.
>
> Any input on the specific technical issue I'm facing would be really helpful.
> One caveat that I'm struggling with is that we have about five developers
> building different modules and I'd like them to be doing as little
> module-specific bootstrapping/configuration/etc as possible so they can just
> build the meat of each module and drop it in, but I'm beyond my own technical
> know-how at this point.
>
> Thanks!
>
> View message @
> http://n4.nabble.com/Conceptual-Technical-Question-for-Multiple-Module-App-ZF-1-10-tp1754760p1754760.html
>
> To start a new topic under Zend Framework, email
> [email protected]
> To unsubscribe from Zend Framework, click here.
>