|
Hi,
I have two module directories: default and test. This is an attempt to set up a very basic module structure in order to understand the new bootstrapping. In application.ini I basically do resources.frontController.moduleDirectory = APPLICATION_PATH "/modules" resources.modules[] = which works fine, as I can access the controllers. Adding an empty Bootstrap.php to the test module directory makes it possible to instantiate models from the test directory - nice. But when I try to instantiate a model from the default module directory, I get the error message that the class could not be found. What do I have to set in the application.ini in order to treat the default module directory like all the others? I tried adding an empty Bootstrap.php to the default directory, I tried the prefixDefaultModule and other options in the application.ini (but that lead to odd errors) and I tried all kinds of typos (Default_Model_TestModel, Model_TestModel etc) - nothing worked. Any help is highly appreciated. :) -- Cheers, \\|// Vince (o o) ----------------------------ooO-(_)-Ooo------------------------- ''' (o)_(o) [ ][0][ ] ô¿ô (=°o°=) World Domination by Copy and Paste [ ][ ][0] - (")_(") [0][0][0] () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments Ooo. ---------------------------.ooO----( )------------------------- ( ) (_/ \_) |
|
On Thursday 25 June 2009 23:54:41 Vince42 wrote:
> Hi, > > I have two module directories: default and test. > > This is an attempt to set up a very basic module structure in order to > understand the new bootstrapping. > > In application.ini I basically do > > resources.frontController.moduleDirectory = APPLICATION_PATH "/modules" > resources.modules[] = > > which works fine, as I can access the controllers. > > Adding an empty Bootstrap.php to the test module directory makes it > possible to instantiate models from the test directory - nice. > > But when I try to instantiate a model from the default module directory, > I get the error message that the class could not be found. > > What do I have to set in the application.ini in order to treat the > default module directory like all the others? > > I tried adding an empty Bootstrap.php to the default directory, I tried > the prefixDefaultModule and other options in the application.ini (but > that lead to odd errors) and I tried all kinds of typos > (Default_Model_TestModel, Model_TestModel etc) - nothing worked. This has become a FAQ and IMHO should be addressed in the doc. The default module is by design considered somewhat different from other modules (to be non-portable from app to app, to be exact) and it's bootstrap class is considered to be the "main bootstrap" class which you use for your entire app. I think we should rethink this as it's obvious many people use the default module just like any other so the behavior should be as expected, even if adding an additional option. -- Dado |
|
Hi,
Dalibor Karlović schrieb: > I think we should rethink this as it's obvious many people use the > default module just like any other so the behavior should be as > expected, even if adding an additional option. I circumvented this odd behaviour with http://paste2.org/p/284720 but I think that this is ugly and - if not provided otherwise - ZF should treat the default module exactly as you described it and everybody would expect it to work. Unfortunately the Quickstart is omitting the module topic - and I really think that the module approach should be enforced as it leaves much more room for flexibility, self-contained / autarchic modules etc ... just my two cents. :) -- Cheers, \\|// Vince (o o) ----------------------------ooO-(_)-Ooo------------------------- ''' (o)_(o) [ ][0][ ] ô¿ô (=°o°=) World Domination by Copy and Paste [ ][ ][0] - (")_(") [0][0][0] () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments Ooo. ---------------------------.ooO----( )------------------------- ( ) (_/ \_) |
|
2009/6/25 Vince42 <[hidden email]>:
> Hi, > > Dalibor Karlović schrieb: >> I think we should rethink this as it's obvious many people use the >> default module just like any other so the behavior should be as >> expected, even if adding an additional option. > > I circumvented this odd behaviour with > > http://paste2.org/p/284720 You need to configure the autoloader in your main bootstrap for the default module, something like: $this->_resourceLoader = new Zend_Application_Module_Autoloader(array( 'namespace' => 'Default', 'basePath' => APPLICATION_PATH . '/modules/default', )); This then expects models etc like Default_Model_MyModel, Default_Form_MyForm. I find it best to name the default module though like this: resources.frontcontroller.defaultmodule = "mynamespace" resources.frontcontroller.params.prefixDefaultModule = true and then use: $this->_resourceLoader = new Zend_Application_Module_Autoloader(array( 'namespace' => 'Mynamespace', 'basePath' => APPLICATION_PATH . '/modules/mynamespace', )); This way all your modules are properly namespaced so you can use them in other projects etc. > > but I think that this is ugly and - if not provided otherwise - ZF > should treat the default module exactly as you described it and > everybody would expect it to work. > > Unfortunately the Quickstart is omitting the module topic - and I really > think that the module approach should be enforced as it leaves much more > room for flexibility, self-contained / autarchic modules etc ... just my > two cents. :) > > -- > Cheers, \\|// > Vince (o o) > ----------------------------ooO-(_)-Ooo------------------------- > ''' (o)_(o) [ ][0][ ] > ô¿ô (=°o°=) World Domination by Copy and Paste [ ][ ][0] > - (")_(") [0][0][0] > > () ascii ribbon campaign - against html e-mail > /\ www.asciiribbon.org - against proprietary attachments > Ooo. > ---------------------------.ooO----( )------------------------- > ( ) (_/ > \_) > > -- ---------------------------------------------------------------------- [MuTe] ---------------------------------------------------------------------- |
|
In reply to this post by Vince42
I agree, modules (and auth and acl) should be added to the QuickStart or some other Zend provided example. I can't think of any real world application that will not need these three additional capabilities.
- Steve W.
|
|
In reply to this post by keith Pope-4
Hi,
keith Pope schrieb: > I find it best to name the default module though > like this: > > resources.frontcontroller.defaultmodule = "mynamespace" > resources.frontcontroller.params.prefixDefaultModule = true > > and then use: > > $this->_resourceLoader = new Zend_Application_Module_Autoloader(array( > 'namespace' => 'Mynamespace', > 'basePath' => APPLICATION_PATH . '/modules/mynamespace', > )); > > This way all your modules are properly namespaced so you can use them > in other projects etc. Besides this working solution it would be more logical that a plain Bootstrap.php in the default directory takes care of the autoloading as it does for non-default modules, because these lines of code are simply superfluous if not irritating. -- Cheers, \\|// Vince (o o) ----------------------------ooO-(_)-Ooo------------------------- ''' (o)_(o) [ ][0][ ] ô¿ô (=°o°=) World Domination by Copy and Paste [ ][ ][0] - (")_(") [0][0][0] () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments Ooo. ---------------------------.ooO----( )------------------------- ( ) (_/ \_) |
|
In reply to this post by swilhelm
Hi,
swilhelm schrieb: > I agree, modules (and auth and acl) should be added to the QuickStart > or some other Zend provided example. I can't think of any real world > application that will not need these three additional capabilities. That's exactly why I am currently trying to port the guestbook example to a modularized version - maybe I'll post about it, when it's done. :) -- Cheers, \\|// Vince (o o) ----------------------------ooO-(_)-Ooo------------------------- ''' (o)_(o) [ ][0][ ] ô¿ô (=°o°=) World Domination by Copy and Paste [ ][ ][0] - (")_(") [0][0][0] () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments Ooo. ---------------------------.ooO----( )------------------------- ( ) (_/ \_) |
|
2009/6/26 Vince42 <[hidden email]>:
> Hi, > > swilhelm schrieb: >> I agree, modules (and auth and acl) should be added to the QuickStart >> or some other Zend provided example. I can't think of any real world >> application that will not need these three additional capabilities. > > That's exactly why I am currently trying to port the guestbook example > to a modularized version - maybe I'll post about it, when it's done. :) If you are interested in examples using modules, acl, caching, auth, testing etc I have a sample storefront on google code: http://code.google.com/p/zendframeworkstorefront/ The code is pretty much complete now, though I will be adding bits later on I hope. > > -- > Cheers, \\|// > Vince (o o) > ----------------------------ooO-(_)-Ooo------------------------- > ''' (o)_(o) [ ][0][ ] > ô¿ô (=°o°=) World Domination by Copy and Paste [ ][ ][0] > - (")_(") [0][0][0] > > () ascii ribbon campaign - against html e-mail > /\ www.asciiribbon.org - against proprietary attachments > Ooo. > ---------------------------.ooO----( )------------------------- > ( ) (_/ > \_) > > -- ---------------------------------------------------------------------- [MuTe] ---------------------------------------------------------------------- |
|
In reply to this post by Vince42
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1 Vince42 wrote: > That's exactly why I am currently trying to port the guestbook example > to a modularized version - maybe I'll post about it, when it's done. :) Sounds like a good idea :) I've posted about how I modularized the guestbook application from quickstart. http://blog.tekerson.com/2009/06/17/building-a-modular-application-in-zend-framework-part-1/ http://blog.tekerson.com/2009/06/27/building-a-modular-application-in-zend-framework-part-2/ I've also included a github repository with the complete application. Feedback appreciated. - -- Brenton Alker PHP Developer - Brisbane, Australia http://blog.tekerson.com/ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkpFrc0ACgkQ7bkAtAithuvQogCbBBL1QtsCvb82sVxoVe7bMEuN f+YAoMTRDIrUOTVNl9nvfXuls1LqTf31 =w93K -----END PGP SIGNATURE----- |
| Powered by Nabble | Edit this page |
