Re: [fw-general] Model Loading helper (Everyone likes diagrams!)
How about this? Zend_Loader::loadClass('Users', dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'models'); I can almost hear the boos, but it works for a conventional modular layout. Personally I'd like to see Zend_Controller_Action provide the info so I could do this: Zend_Loader::loadClass('Users', $this->getModuleDirectory() . DIRECTORY_SEPARATOR . 'models'); No need for another helper class. No need to bloat your include_path or bloat your boostrap. Correct me if I'm wrong but I think Padraic advocates read only model access from views so not sure that this would help in that, but I'm almost excited about the big throwdown at: http://framework.zend.com/wiki/display/ZFDEV/Zend_View+Enhancement+VS.+Zend_Layout+Throwdown I don't get out much :) Regards, Mark Shahar Evorn wrote: > > I generally like the idea as long as it is kept optional. I personally > like to load models by defining a model path (eg. APP_MODEL_DIR) > constant in my bootstrap file, and then call > > Zend_Loader::loadClass('User', APP_MODEL_DIR); > > whenever I need to. IMHO it's clean enough and super fast, and I don't > like the idea of loading an extra class and calling some methods just > for loading a model class. > > Shahar. > -- View this message in context: http://www.nabble.com/Model-Loading-helper-tf3942096s16154.html#a11345909 Sent from the Zend Framework mailing list archive at Nabble.com.
Re: [fw-general] Model Loading helper (Everyone likes diagrams!)
Indeed Ralph I've been envisioning a repository of 'modules' that developers could share with each other that could standalone. Like a forums module, a blog module, a generic login module, a feed generator module, a simple CMS table-editor module, etc... So I download a module, untar it and drop it into my ZF site with a minimum of fuss. With components like these I can be reasonably sure that it is self-contained and references its own Models, Views, Helpers, etc without relying too much on what I've done with my bootstrap file. May not happen soon but I do like the way ZF is shaping up to allow such a possibility. Shahar Evron wrote: I generally like the idea as long as it is kept optional. I personally like to load models by defining a model path (eg. APP_MODEL_DIR) constant in my bootstrap file, and then call Zend_Loader::loadClass('User', APP_MODEL_DIR); I completely agree with you there, and yes, it would be an optional component of course, and what you describe works well in non-modular environments. whenever I need to. IMHO it's clean enough and super fast, and I don't like the idea of loading an extra class and calling some methods just for loading a model class. ModelLoader becomes important for fulfilling the role of finding the path to models (usually based on some convention) that belong to an in-use component. The requirements this component fulfills is a) ability to allow modules to take control of the loading of models and model paths with the system b) not require the bootstrap to be completely aware of all modules conventions and paths to models c) ability to register paths on on-demand and when modules are in-use d) use Zend_Loader::loadClass() so that autoloading is not required, thus allowing op-code caches better cacheability since LoadClass() results in a require_once. (theoretically). That being said, I still think there is a lot of value in such a component. -ralph -- Simon Mundy | Director | PEPTOLAB """ " "" "" "" "" """ " "" " " " " "" "" " 202/258 Flinders Lane | Melbourne | Victoria | Australia | 3000 Voice +61 (0) 3 9654 4324 | Mobile 0438 046 061 | Fax +61 (0) 3 9654 4124 http://www.peptolab.com
Re: [fw-general] Model Loading helper (Everyone likes diagrams!)
Shahar Evron wrote: I generally like the idea as long as it is kept optional. I personally like to load models by defining a model path (eg. APP_MODEL_DIR) constant in my bootstrap file, and then call Zend_Loader::loadClass('User', APP_MODEL_DIR); I completely agree with you there, and yes, it would be an optional component of course, and what you describe works well in non-modular environments. whenever I need to. IMHO it's clean enough and super fast, and I don't like the idea of loading an extra class and calling some methods just for loading a model class. ModelLoader becomes important for fulfilling the role of finding the path to models (usually based on some convention) that belong to an in-use component. The requirements this component fulfills is a) ability to allow modules to take control of the loading of models and model paths with the system b) not require the bootstrap to be completely aware of all modules conventions and paths to models c) ability to register paths on on-demand and when modules are in-use d) use Zend_Loader::loadClass() so that autoloading is not required, thus allowing op-code caches better cacheability since LoadClass() results in a require_once. (theoretically). That being said, I still think there is a lot of value in such a component. -ralph
Re: [fw-general] Model Loading helper (Everyone likes diagrams!)
I generally like the idea as long as it is kept optional. I personally like to load models by defining a model path (eg. APP_MODEL_DIR) constant in my bootstrap file, and then call Zend_Loader::loadClass('User', APP_MODEL_DIR); whenever I need to. IMHO it's clean enough and super fast, and I don't like the idea of loading an extra class and calling some methods just for loading a model class. Shahar. On Mon, 2007-06-18 at 14:09 -0500, Ralph Schindler wrote: > Thus fitting into this visual representation: > > http://ralphschindler.com/tmp/ZF-MVC-Diagram.jpg > > > PS: we need more diagrams in ZF docs ;) -- Shahar Evron [EMAIL PROTECTED] Technical Consultant Zend Technologies Mobile: +972 54 30 99 446 Office: +972 3 75 39 500 ext. 9546 signature.asc Description: This is a digitally signed message part
Re: [fw-general] Model Loading helper (Everyone likes diagrams!)
Thus fitting into this visual representation: http://ralphschindler.com/tmp/ZF-MVC-Diagram.jpg PS: we need more diagrams in ZF docs ;)