2009年9月22日星期二

Re: [fw-mvc] How to autoload my models?

I added, but still not work!

I think if I notice the framework that i add a module, the framework should find it and load it on need, right?

And I alse added the model folder to include_path, I wonder why it couldn't find the class? 

2009/9/23 Matthew Lurz <mlurz71@gmail.com>
Add a bootstrap to the module which extends Zend_Application_Module_Bootstrap.

(Also, note that your main bootstrap extends Zend_Application_Bootstrap_Bootstrap instead)

So, create application/modules/user/Bootstrap.php with the following:

class User_Bootstrap extends Zend_Application_Module_Bootstrap
{

}

On Wed, 23 Sep 2009, huajun qi wrote:

Thanks.
But I cannot understand what do you mean. I have
used $front->addModuleDirectory() to my bootstrap.php file. I think it had
told the system that I have added a new module, and the position!



2009/9/23 Kyle Spraggs <theman@spiffyjr.me>

On 9/22/2009 9:40 PM, huajun qi wrote:

I created some models extending Zend_Db_Table Class and put it under
application/modules/user/models/ directory?

But how can I make them autoloaded?

I add the path to include_path, but i didn't work.

--
Location:

You need to initialize the autoloader. My models are placed in
application/models/ and I do the following in my bootstrap.

  protected function _initAutoload()
  {
      $autoloader = new Zend_Application_Module_Autoloader(
          array('namespace' => 'Default', 'basePath' =>
dirname(__FILE__)));
  }

This allows me to autoload modules using $model = new Default_Model_Name();

--
Kyle Spraggs (SpiffyJr)
http://www.spiffyjr.me




--
Location:




--
Location:

没有评论: