Re: [fw-general] Bootstrapping modules and testing
Davout wrote: When I run phpunit in the tests directory I get Fatal error: Class 'Zend_Application_Bootstrap_Bootstrap' not found in C:\code\myApp\application\Bootstrap.php on line 3 Ok I got past that problem, but now Running MAMP/bin/php5/bin/phpunit --configuration phpunit.xml --verbose doesn't produce any output. I have application/modules/order/models/OrderRepository.php ?php class Order_Model_OrderRepository { ... } - I have tests/ModelTestCase.php ?php require_once 'Zend/Application.php'; abstract class ModelTestCase extends PHPUnit_Framework_TestCase { public $application; public function setUp() { $this-application = new Zend_Application( APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini' ); $this-bootstrap = array($this, 'appBootstrap'); parent::setUp(); } public function appBootstrap() { $this-application-bootstrap(); } } I have tests/application/modules/order/models/OrderRepository.php ?php class Order_Model_OrderRepositoryTest extends ModelTestCase { protected function setUp(){ parent::setUp(); } public function testFind() { $orderRepos = new Order_Model_OrderRepository(); $this-assertEquals(1, 2); // should produce failure! } } Any ideas? Thanks. -- View this message in context: http://n4.nabble.com/Bootstrapping-modules-and-testing-tp680333p758618.html Sent from the Zend Framework mailing list archive at Nabble.com.
Re: [fw-general] Bootstrapping modules and testing
One correction. I previously posted tests/application/modules/order/models/OrderRepository.php the filename is actually OrderRepositoryTest.php One other thing in tests/application/controllers I have IndexControllerTest.php ?php class IndexControllerTest extends ControllerTestCase { public function testIndexAction() { $this-dispatch('/'); $this-assertController('index'); $this-assertAction('index'); } public function testErrorURL() { $this-dispatch('foo'); $this-assertController('error'); $this-assertAction('error'); } } If I remove tests/application/modules/order/models/OrderRepositoryTest.php then IndexControllerTest produces output. I put OrderRepositoryTest.php back, no output from any tests. Thanks. -- View this message in context: http://n4.nabble.com/Bootstrapping-modules-and-testing-tp680333p758620.html Sent from the Zend Framework mailing list archive at Nabble.com.
Re: [fw-general] Bootstrapping modules and testing
Never mind. I got it to work. Apparently, at some point in the hierarchy I have to extend Zend_Test_PHPUnit_ControllerTestCase class Order_Model_OrderRepositoryTest extends ControllerTestCase class ControllerTestCase extends Zend_Test_PHPUnit_ControllerTestCase -- View this message in context: http://n4.nabble.com/Bootstrapping-modules-and-testing-tp680333p758621.html Sent from the Zend Framework mailing list archive at Nabble.com.
Re: [fw-general] Bootstrapping modules and testing
I don't think you need to extend Zend_Test_PHPUnit_ControllerTestCase for your models. As far as I understand this class is there to provide controllers with methods to make them easily testable. Models should be independant and therefore easily testable anyway. Hope this males sense. On 22 Nov 2009, at 10:04, Davout davout1...@gmail.com wrote: Never mind. I got it to work. Apparently, at some point in the hierarchy I have to extend Zend_Test_PHPUnit_ControllerTestCase class Order_Model_OrderRepositoryTest extends ControllerTestCase class ControllerTestCase extends Zend_Test_PHPUnit_ControllerTestCase -- View this message in context: http://n4.nabble.com/Bootstrapping-modules-and-testing-tp680333p758621.html Sent from the Zend Framework mailing list archive at Nabble.com.
Re: [fw-general] Bootstrapping modules and testing
Daniel Latter wrote: I don't think you need to extend Zend_Test_PHPUnit_ControllerTestCase for your models. As far as I understand this class is there to provide controllers with methods to make them easily testable. Models should be independant and therefore easily testable anyway. Hope this males sense. On 22 Nov 2009, at 10:04, Davout davout1...@gmail.com wrote: Never mind. I got it to work. Apparently, at some point in the hierarchy I have to extend Zend_Test_PHPUnit_ControllerTestCase class Order_Model_OrderRepositoryTest extends ControllerTestCase class ControllerTestCase extends Zend_Test_PHPUnit_ControllerTestCase -- View this message in context: http://n4.nabble.com/Bootstrapping-modules-and-testing-tp680333p758621.html Sent from the Zend Framework mailing list archive at Nabble.com. Daniel, Thanks for the feedback. It makes perfect sense. And that's how I would think it should work. I created ModelTestCase.php ?php require_once 'Zend/Application.php'; abstract class ModelTestCase extends PHPUnit_Framework_TestCase { public $application; public function setUp() { $this-application = new Zend_Application( APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini' ); $this-bootstrap = array($this, 'appBootstrap'); parent::setUp(); } public function appBootstrap() { $this-application-bootstrap(); } } And had my test extend that. However, running test does not generate any output. But now I find out even if I use the ControllerTestCase if my test class implements its own setUp protected function setUp(){ parent::setUp(); } No output is generated. Obviously something in my setup is not correct. Any ideas? Thanks. -- View this message in context: http://n4.nabble.com/Bootstrapping-modules-and-testing-tp680333p758689.html Sent from the Zend Framework mailing list archive at Nabble.com.
Re: [fw-general] Bootstrapping modules and testing
Hi, Have a look here: (Section 9.6) http://www.survivethedeepend.com/zendframeworkbook/en/1.0/implementing.the.domain.model.entries.and.authors It has a pretty good simple example of how to set ZF up with PHPUnit. (if you wonder, the file TestHelper.php referenced can be found in the comments) Thanks Dan 2009/11/22 Davout davout1...@gmail.com Daniel Latter wrote: I don't think you need to extend Zend_Test_PHPUnit_ControllerTestCase for your models. As far as I understand this class is there to provide controllers with methods to make them easily testable. Models should be independant and therefore easily testable anyway. Hope this males sense. On 22 Nov 2009, at 10:04, Davout davout1...@gmail.com wrote: Never mind. I got it to work. Apparently, at some point in the hierarchy I have to extend Zend_Test_PHPUnit_ControllerTestCase class Order_Model_OrderRepositoryTest extends ControllerTestCase class ControllerTestCase extends Zend_Test_PHPUnit_ControllerTestCase -- View this message in context: http://n4.nabble.com/Bootstrapping-modules-and-testing-tp680333p758621.html Sent from the Zend Framework mailing list archive at Nabble.com. Daniel, Thanks for the feedback. It makes perfect sense. And that's how I would think it should work. I created ModelTestCase.php ?php require_once 'Zend/Application.php'; abstract class ModelTestCase extends PHPUnit_Framework_TestCase { public $application; public function setUp() { $this-application = new Zend_Application( APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini' ); $this-bootstrap = array($this, 'appBootstrap'); parent::setUp(); } public function appBootstrap() { $this-application-bootstrap(); } } And had my test extend that. However, running test does not generate any output. But now I find out even if I use the ControllerTestCase if my test class implements its own setUp protected function setUp(){ parent::setUp(); } No output is generated. Obviously something in my setup is not correct. Any ideas? Thanks. -- View this message in context: http://n4.nabble.com/Bootstrapping-modules-and-testing-tp680333p758689.html Sent from the Zend Framework mailing list archive at Nabble.com.
[fw-general] Bootstrapping modules and testing
Hi, I'm having problems running phpunit tests for my Zend application. I'm wondering if anyone could correct what I'm doing wrong. I've setup my application based on http://akrabat.com/2009/07/08/bootstrapping-modules-in-zf-1-8/ Rob Allen's Bootstrapping Modules blog post. Note: right now I'm not trying to test controllers, just model classes In my tests directory I have phpunit.xml and TestHelper.php phpunit.xml phpunit bootstrap=./TestHelper.php colors=true testsuite name=Zend Framework Unit Testing directory./directory /testsuite filter whitelist directory suffix=.php../library/directory directory suffix=.php../application/directory exclude directory suffix=.phtml../application/directory /exclude /whitelist /filter /phpunit TestHelper.php ?php /** * Set the environment to be testing. */ define('APPLICATION_ENVIRONMENT', 'testing'); /** * Sets the application path constant for file inclusion. */ define('APPLICATION_PATH', realpath(dirname(dirname(__FILE__)) . '/application/')); /** * Make the library/ sub-folder an include path. */ set_include_path( APPLICATION_PATH . '/../library' . PATH_SEPARATOR . get_include_path() ); echo get_include_path(); /** * Include the bootstrap file for testing - this is the same file used when * running the actual application. */ require_once '../application/bootstrap.php'; ? My Bootstrap.php in application/ ?php class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { protected function _initAutoload() { $moduleLoader = new Zend_Application_Module_Autoloader(array( 'namespace' = '', 'basePath' = APPLICATION_PATH)); return $moduleLoader; } } ? When I run phpunit in the tests directory I get Fatal error: Class 'Zend_Application_Bootstrap_Bootstrap' not found in C:\code\myApp\application\Bootstrap.php on line 3 The include path echoed is: C:\code\myApp\application/../library;.;C:\xampp\php\pear\ Thanks for any help. -- View this message in context: http://n4.nabble.com/Bootstrapping-modules-and-testing-tp680333p680333.html Sent from the Zend Framework mailing list archive at Nabble.com.
Re: [fw-general] Bootstrapping modules
OK i have added a bootsrap.php file for each module in the module root directory. For some reason it won't load that bootstrap file. For example my default module directory is as follows: -default --bootsrap.php --controllers --layouts --views my bootsrap.php file has the class Default_Bootstrap extends Zend_Application_Module_Bootstrap and it consists of an _initView method which never gets called. but it routes to the index controller of the default module. Meaning it works just with nothing set, not view, no layout no nothing. Any idea why? Thanks. On Wed, May 6, 2009 at 6:24 PM, Vadim Gabriel vadim...@gmail.com wrote: P.S I do not use the Zend_Tool yet since it doesn't support modules...Yet (as far as i know) On Wed, May 6, 2009 at 6:23 PM, Vadim Gabriel vadim...@gmail.com wrote: Thanks everyone, I think since there are so many people wondering about it, A blog post/tutorial will be a good idea *hint Matthew hint* i will take a look at those once i am at the office tomorrow. Vince. On Wed, May 6, 2009 at 5:33 PM, Jurian Sluiman subscr...@juriansluiman.nl wrote: I think (but am not sure about it) you can add view helper paths in the module bootstrap. You need to specify them for each module, that's correct. But it's not much work to have an init method in each bootstrap class adding a path to the view (only some duplicated code...). -- Jurian Sluiman Soflomo.com Op Wednesday 06 May 2009 16:27:31 schreef Karl: Hi, I've been trying to configure the same setup as mentioned and was having issues trying to get my view helpers registered in the modules. You will have to register your view helper paths in each modules bootstrap file. regards, Karl _ From: Jurian Sluiman [mailto:subscr...@juriansluiman.nl] Sent: 06 May 2009 04:03 PM To: fw-general@lists.zend.com Subject: Re: [fw-general] Bootstrapping modules Op Wednesday 06 May 2009 14:57:00 schreef Vadim Gabriel: Hey, Are there any tutorials/guides out there that show examples on ways to bootstrap an application using more then one module? I mean if i have a directory structure like this: -library ---Zend -public ---admin -default -other ---site -default -other ---index.php -application ---configs -application.ini ---modules -admin ---controllers ---layouts -scripts ---default ---other ---views -scripts ---default ---other -helpers -site ---controllers ---layouts -scripts ---default ---other ---views -scripts ---default ---other -helpers Basically i am looking for creating a modeler structure application using ZF 1.8, Is there anything blogged about it? Thanks. Hi Vadim, I have looked into this problem as well. It isn't mentioned in the manual, but it's very simple. You should add a Bootstrap.php in each module root containing the class {ModuleName}_Bootstrap, e.g. Admin_Bootstrap, and extending it from Zend_Application_Module_Bootstrap. Now make sure you initialise the modules resource in the global bootstrap class by adding this to your application.ini (if you pass a Zend_Config object when creating the Zend_Application instance): resources.modules[] = Now you should have a proper modular design with autoloading the modules using the conventional structure. Regards, Jurian -- Vincent Gabriel. Lead Developer, Senior Support. Zend Certified Engineer. Zend Framework Certified Engineer. -- http://www.vadimg.co.il/ -- Vincent Gabriel. Lead Developer, Senior Support. Zend Certified Engineer. Zend Framework Certified Engineer. -- http://www.vadimg.co.il/ -- Vincent Gabriel. Lead Developer, Senior Support. Zend Certified Engineer. Zend Framework Certified Engineer. -- http://www.vadimg.co.il/
Re: [fw-general] Bootstrapping modules
2009/5/7 Vadim Gabriel vadim...@gmail.com: OK i have added a bootsrap.php file for each module in the module root directory. For some reason it won't load that bootstrap file. For example my default module directory is as follows: -default --bootsrap.php --controllers --layouts --views my bootsrap.php file has the class Default_Bootstrap extends Zend_Application_Module_Bootstrap and it consists of an _initView method which never gets called. but it routes to the index controller of the default module. Meaning it works just with nothing set, not view, no layout no nothing. Currently the default module is skipped, look inside the modules resource to see. Therefore Zend_App assume that the main bootstrap file is your default bootstrap file. This will change at some point, I had a conversation with Matthew about it some time ago and there are various ideas about configuring individual modules. I have an example of bootstrapping with modules here: http://code.google.com/p/zendframeworkstorefront I should be updating it in the next few weeks to include multiple modules as currently it has only one. Also I use a route to create the admin section rather than a separate module, this way you can keep all your module code together in one place. Hope that makes sense :) Any idea why? Thanks. On Wed, May 6, 2009 at 6:24 PM, Vadim Gabriel vadim...@gmail.com wrote: P.S I do not use the Zend_Tool yet since it doesn't support modules...Yet (as far as i know) On Wed, May 6, 2009 at 6:23 PM, Vadim Gabriel vadim...@gmail.com wrote: Thanks everyone, I think since there are so many people wondering about it, A blog post/tutorial will be a good idea *hint Matthew hint* i will take a look at those once i am at the office tomorrow. Vince. On Wed, May 6, 2009 at 5:33 PM, Jurian Sluiman subscr...@juriansluiman.nl wrote: I think (but am not sure about it) you can add view helper paths in the module bootstrap. You need to specify them for each module, that's correct. But it's not much work to have an init method in each bootstrap class adding a path to the view (only some duplicated code...). -- Jurian Sluiman Soflomo.com Op Wednesday 06 May 2009 16:27:31 schreef Karl: Hi, I've been trying to configure the same setup as mentioned and was having issues trying to get my view helpers registered in the modules. You will have to register your view helper paths in each modules bootstrap file. regards, Karl _ From: Jurian Sluiman [mailto:subscr...@juriansluiman.nl] Sent: 06 May 2009 04:03 PM To: fw-general@lists.zend.com Subject: Re: [fw-general] Bootstrapping modules Op Wednesday 06 May 2009 14:57:00 schreef Vadim Gabriel: Hey, Are there any tutorials/guides out there that show examples on ways to bootstrap an application using more then one module? I mean if i have a directory structure like this: -library ---Zend -public ---admin -default -other ---site -default -other ---index.php -application ---configs -application.ini ---modules -admin ---controllers ---layouts -scripts ---default ---other ---views -scripts ---default ---other -helpers -site ---controllers ---layouts -scripts ---default ---other ---views -scripts ---default ---other -helpers Basically i am looking for creating a modeler structure application using ZF 1.8, Is there anything blogged about it? Thanks. Hi Vadim, I have looked into this problem as well. It isn't mentioned in the manual, but it's very simple. You should add a Bootstrap.php in each module root containing the class {ModuleName}_Bootstrap, e.g. Admin_Bootstrap, and extending it from Zend_Application_Module_Bootstrap. Now make sure you initialise the modules resource in the global bootstrap class by adding this to your application.ini (if you pass a Zend_Config object when creating the Zend_Application instance): resources.modules[] = Now you should have a proper modular design with autoloading the modules using the conventional structure. Regards, Jurian -- Vincent Gabriel. Lead Developer, Senior Support. Zend Certified Engineer. Zend Framework Certified Engineer. -- http://www.vadimg.co.il/ -- Vincent Gabriel. Lead Developer, Senior Support. Zend Certified Engineer. Zend Framework Certified Engineer. -- http://www.vadimg.co.il/ -- Vincent Gabriel. Lead Developer, Senior Support. Zend Certified Engineer. Zend Framework Certified Engineer. -- http://www.vadimg.co.il/ -- -- [MuTe] --
Re: [fw-general] Bootstrapping modules
Hey, Thanks for that, It's a good start. The reason i want to separate the admin from the other modules is because i will have lots of controllers for each module, Each module will have several layouts, each one has to load different public resources from the public folder so it's important for me to make a complex modeler structure so switching layouts, views, resources, controllers separation and adding more modules at a later time will be easier. Since there are no resources about it, You need to dig trough the PHP files of the ZF to figure out how the ZF works with modules step-by-step that sometimes takes time (too much time). I am still looking to get this done the way i showed above, If your book will cover that area as well then you got yourself your first buyer and reader. Thanks. On Thu, May 7, 2009 at 11:00 AM, keith Pope mute.p...@googlemail.comwrote: 2009/5/7 Vadim Gabriel vadim...@gmail.com: OK i have added a bootsrap.php file for each module in the module root directory. For some reason it won't load that bootstrap file. For example my default module directory is as follows: -default --bootsrap.php --controllers --layouts --views my bootsrap.php file has the class Default_Bootstrap extends Zend_Application_Module_Bootstrap and it consists of an _initView method which never gets called. but it routes to the index controller of the default module. Meaning it works just with nothing set, not view, no layout no nothing. Currently the default module is skipped, look inside the modules resource to see. Therefore Zend_App assume that the main bootstrap file is your default bootstrap file. This will change at some point, I had a conversation with Matthew about it some time ago and there are various ideas about configuring individual modules. I have an example of bootstrapping with modules here: http://code.google.com/p/zendframeworkstorefront I should be updating it in the next few weeks to include multiple modules as currently it has only one. Also I use a route to create the admin section rather than a separate module, this way you can keep all your module code together in one place. Hope that makes sense :) Any idea why? Thanks. On Wed, May 6, 2009 at 6:24 PM, Vadim Gabriel vadim...@gmail.com wrote: P.S I do not use the Zend_Tool yet since it doesn't support modules...Yet (as far as i know) On Wed, May 6, 2009 at 6:23 PM, Vadim Gabriel vadim...@gmail.com wrote: Thanks everyone, I think since there are so many people wondering about it, A blog post/tutorial will be a good idea *hint Matthew hint* i will take a look at those once i am at the office tomorrow. Vince. On Wed, May 6, 2009 at 5:33 PM, Jurian Sluiman subscr...@juriansluiman.nl wrote: I think (but am not sure about it) you can add view helper paths in the module bootstrap. You need to specify them for each module, that's correct. But it's not much work to have an init method in each bootstrap class adding a path to the view (only some duplicated code...). -- Jurian Sluiman Soflomo.com Op Wednesday 06 May 2009 16:27:31 schreef Karl: Hi, I've been trying to configure the same setup as mentioned and was having issues trying to get my view helpers registered in the modules. You will have to register your view helper paths in each modules bootstrap file. regards, Karl _ From: Jurian Sluiman [mailto:subscr...@juriansluiman.nl] Sent: 06 May 2009 04:03 PM To: fw-general@lists.zend.com Subject: Re: [fw-general] Bootstrapping modules Op Wednesday 06 May 2009 14:57:00 schreef Vadim Gabriel: Hey, Are there any tutorials/guides out there that show examples on ways to bootstrap an application using more then one module? I mean if i have a directory structure like this: -library ---Zend -public ---admin -default -other ---site -default -other ---index.php -application ---configs -application.ini ---modules -admin ---controllers ---layouts -scripts ---default ---other ---views -scripts ---default ---other -helpers -site ---controllers ---layouts -scripts ---default ---other ---views -scripts ---default ---other -helpers Basically i am looking for creating a modeler structure application using ZF 1.8, Is there anything blogged about it? Thanks. Hi Vadim, I have looked into this problem as well. It isn't mentioned in the manual, but it's very simple. You should add a Bootstrap.php in each module root containing the class {ModuleName}_Bootstrap, e.g. Admin_Bootstrap, and extending
Re: [fw-general] Bootstrapping modules
Sluiman Soflomo.com Op Wednesday 06 May 2009 16:27:31 schreef Karl: Hi, I've been trying to configure the same setup as mentioned and was having issues trying to get my view helpers registered in the modules. You will have to register your view helper paths in each modules bootstrap file. regards, Karl _ From: Jurian Sluiman [mailto:subscr...@juriansluiman.nl] Sent: 06 May 2009 04:03 PM To: fw-general@lists.zend.com Subject: Re: [fw-general] Bootstrapping modules Op Wednesday 06 May 2009 14:57:00 schreef Vadim Gabriel: Hey, Are there any tutorials/guides out there that show examples on ways to bootstrap an application using more then one module? I mean if i have a directory structure like this: -library ---Zend -public ---admin -default -other ---site -default -other ---index.php -application ---configs -application.ini ---modules -admin ---controllers ---layouts -scripts ---default ---other ---views -scripts ---default ---other -helpers -site ---controllers ---layouts -scripts ---default ---other ---views -scripts ---default ---other -helpers Basically i am looking for creating a modeler structure application using ZF 1.8, Is there anything blogged about it? Thanks. Hi Vadim, I have looked into this problem as well. It isn't mentioned in the manual, but it's very simple. You should add a Bootstrap.php in each module root containing the class {ModuleName}_Bootstrap, e.g. Admin_Bootstrap, and extending it from Zend_Application_Module_Bootstrap. Now make sure you initialise the modules resource in the global bootstrap class by adding this to your application.ini (if you pass a Zend_Config object when creating the Zend_Application instance): resources.modules[] = Now you should have a proper modular design with autoloading the modules using the conventional structure. Regards, Jurian -- Vincent Gabriel. Lead Developer, Senior Support. Zend Certified Engineer. Zend Framework Certified Engineer. -- http://www.vadimg.co.il/ -- Vincent Gabriel. Lead Developer, Senior Support. Zend Certified Engineer. Zend Framework Certified Engineer. -- http://www.vadimg.co.il/ -- Vincent Gabriel. Lead Developer, Senior Support. Zend Certified Engineer. Zend Framework Certified Engineer. -- http://www.vadimg.co.il/ -- -- [MuTe] -- -- Vincent Gabriel. Lead Developer, Senior Support. Zend Certified Engineer. Zend Framework Certified Engineer. -- http://www.vadimg.co.il/
Re: [fw-general] Bootstrapping modules
subscr...@juriansluiman.nl wrote: I think (but am not sure about it) you can add view helper paths in the module bootstrap. You need to specify them for each module, that's correct. But it's not much work to have an init method in each bootstrap class adding a path to the view (only some duplicated code...). -- Jurian Sluiman Soflomo.com Op Wednesday 06 May 2009 16:27:31 schreef Karl: Hi, I've been trying to configure the same setup as mentioned and was having issues trying to get my view helpers registered in the modules. You will have to register your view helper paths in each modules bootstrap file. regards, Karl _ From: Jurian Sluiman [mailto:subscr...@juriansluiman.nl] Sent: 06 May 2009 04:03 PM To: fw-general@lists.zend.com Subject: Re: [fw-general] Bootstrapping modules Op Wednesday 06 May 2009 14:57:00 schreef Vadim Gabriel: Hey, Are there any tutorials/guides out there that show examples on ways to bootstrap an application using more then one module? I mean if i have a directory structure like this: -library ---Zend -public ---admin -default -other ---site -default -other ---index.php -application ---configs -application.ini ---modules -admin ---controllers ---layouts -scripts ---default ---other ---views -scripts ---default ---other -helpers -site ---controllers ---layouts -scripts ---default ---other ---views -scripts ---default ---other -helpers Basically i am looking for creating a modeler structure application using ZF 1.8, Is there anything blogged about it? Thanks. Hi Vadim, I have looked into this problem as well. It isn't mentioned in the manual, but it's very simple. You should add a Bootstrap.php in each module root containing the class {ModuleName}_Bootstrap, e.g. Admin_Bootstrap, and extending it from Zend_Application_Module_Bootstrap. Now make sure you initialise the modules resource in the global bootstrap class by adding this to your application.ini (if you pass a Zend_Config object when creating the Zend_Application instance): resources.modules[] = Now you should have a proper modular design with autoloading the modules using the conventional structure. Regards, Jurian -- Vincent Gabriel. Lead Developer, Senior Support. Zend Certified Engineer. Zend Framework Certified Engineer. -- http://www.vadimg.co.il/ -- Vincent Gabriel. Lead Developer, Senior Support. Zend Certified Engineer. Zend Framework Certified Engineer. -- http://www.vadimg.co.il/ -- Vincent Gabriel. Lead Developer, Senior Support. Zend Certified Engineer. Zend Framework Certified Engineer. -- http://www.vadimg.co.il/ -- -- [MuTe] -- -- Vincent Gabriel. Lead Developer, Senior Support. Zend Certified Engineer. Zend Framework Certified Engineer. -- http://www.vadimg.co.il/ -- -- [MuTe] --
FW: [fw-general] Bootstrapping modules
I have the same problem, but I THINK I am near the solution. Try to add on your 1.8 bootstrap this method protected function _initFront(){ $config = new Zend_Config_Ini(CONFIGS_PATH.'application.ini',APPLICATION_ENV); // you can skip this $frontController = Zend_Controller_Front::getInstance(); $frontController-throwExceptions((bool)$config-front-throwExceptions); // you can skip this $frontController-returnResponse((bool)$config-front-returnResponse); // you can skip this $frontController-registerPlugin(new Zend_Controller_Plugin_ErrorHandler()); $frontController-setControllerDirectory( array( 'default' = APPLICATION_PATH.'default/controllers', 'admin' = APPLICATION_PATH.'admin/controllers' ) ); $frontController-setParam('useDefaultControllerAlways', true); // Istanziamo router $router = $frontController-getRouter(); // Aggiunta della route contenente la lingua $route = new Zend_Controller_Router_Route(':module/*'); $router-addRoute('byModule', $route); } where the important part is setControllerDirectory method, the route byModule and this line $frontController-setParam('useDefaultControllerAlways', true); Also add this on your initView method ( or where you like I think... ) Zend_Layout::startMvc( array( 'layoutPath' = APPLICATION_PATH.'default'.DS.'views'.DS.'layouts', 'layout' = 'default', 'pluginClass' = 'My_Layout_Controller_Plugin_Layout' ) ); Where My_Layout_Controller_Plugin_Layout basically is class My_Layout_Controller_Plugin_Layout extends Zend_Layout_Controller_Plugin_Layout { public function preDispatch(Zend_Controller_Request_Abstract $request){ $controller = strtoupper($request-getControllerName()); $action = strtoupper($request-getActionName()); echo $request-getModuleName(); // you will get it exit; } } and is saved in library/My/Layout/Controller/Plugin/Layout.php. This Controller Plugin will help you switching layouts. I'm working on it right now... Hope this helps Sergio Rinaudo Date: Wed, 6 May 2009 15:57:00 +0300 From: vadim...@gmail.com To: fw-general@lists.zend.com Subject: [fw-general] Bootstrapping modules Hey, Are there any tutorials/guides out there that show examples on ways to bootstrap an application using more then one module? I mean if i have a directory structure like this: -library ---Zend -public ---admin -default -other ---site -default -other ---index.php -application ---configs -application.ini ---modules -admin ---controllers ---layouts -scripts ---default ---other ---views -scripts ---default ---other -helpers -site ---controllers ---layouts -scripts ---default ---other ---views -scripts ---default ---other -helpers Basically i am looking for creating a modeler structure application using ZF 1.8, Is there anything blogged about it? Thanks. -- Vincent Gabriel. Lead Developer, Senior Support. Zend Certified Engineer. Zend Framework Certified Engineer. -- http://www.vadimg.co.il/ Scrivi, parla e gioca con i tuoi amici! Scarica Messenger 2009! _ PiĆ¹ di 100 Emoticon gratis per il tuo Messenger! http://intrattenimento.it.msn.com/emoticon
Re: [fw-general] Bootstrapping modules
Op Wednesday 06 May 2009 14:57:00 schreef Vadim Gabriel: Hey, Are there any tutorials/guides out there that show examples on ways to bootstrap an application using more then one module? I mean if i have a directory structure like this: -library ---Zend -public ---admin -default -other ---site -default -other ---index.php -application ---configs -application.ini ---modules -admin ---controllers ---layouts -scripts ---default ---other ---views -scripts ---default ---other -helpers -site ---controllers ---layouts -scripts ---default ---other ---views -scripts ---default ---other -helpers Basically i am looking for creating a modeler structure application using ZF 1.8, Is there anything blogged about it? Thanks. Hi Vadim, I have looked into this problem as well. It isn't mentioned in the manual, but it's very simple. You should add a Bootstrap.php in each module root containing the class {ModuleName}_Bootstrap, e.g. Admin_Bootstrap, and extending it from Zend_Application_Module_Bootstrap. Now make sure you initialise the modules resource in the global bootstrap class by adding this to your application.ini (if you pass a Zend_Config object when creating the Zend_Application instance): resources.modules[] = Now you should have a proper modular design with autoloading the modules using the conventional structure. Regards, Jurian
Re: [fw-general] Bootstrapping modules
You should also add resources.frontController.moduleDirectory = APPLICATION_PATH /modules in your application.ini. I believe it's not specified by Zend_Tool by default. -- Mon On Wed, May 6, 2009 at 10:02 PM, Jurian Sluiman subscr...@juriansluiman.nlwrote: Op Wednesday 06 May 2009 14:57:00 schreef Vadim Gabriel: Hey, Are there any tutorials/guides out there that show examples on ways to bootstrap an application using more then one module? I mean if i have a directory structure like this: -library ---Zend -public ---admin -default -other ---site -default -other ---index.php -application ---configs -application.ini ---modules -admin ---controllers ---layouts -scripts ---default ---other ---views -scripts ---default ---other -helpers -site ---controllers ---layouts -scripts ---default ---other ---views -scripts ---default ---other -helpers Basically i am looking for creating a modeler structure application using ZF 1.8, Is there anything blogged about it? Thanks. Hi Vadim, I have looked into this problem as well. It isn't mentioned in the manual, but it's very simple. You should add a Bootstrap.php in each module root containing the class {ModuleName}_Bootstrap, e.g. Admin_Bootstrap, and extending it from Zend_Application_Module_Bootstrap. Now make sure you initialise the modules resource in the global bootstrap class by adding this to your application.ini (if you pass a Zend_Config object when creating the Zend_Application instance): resources.modules[] = Now you should have a proper modular design with autoloading the modules using the conventional structure. Regards, Jurian
Re: [fw-general] Bootstrapping modules
Op Wednesday 06 May 2009 16:16:09 schreef Mon Zafra: You should also add resources.frontController.moduleDirectory = APPLICATION_PATH /modules in your application.ini. I believe it's not specified by Zend_Tool by default. -- Mon Yes, that's true. I forgot to say, but those methods are mentioned in the manual. I've both moduleDirectory and moduleControllerDirectoryName specified in my application.ini, to be sure. Regards, Jurian
RE: [fw-general] Bootstrapping modules
Hi, I've been trying to configure the same setup as mentioned and was having issues trying to get my view helpers registered in the modules. You will have to register your view helper paths in each modules bootstrap file. regards, Karl _ From: Jurian Sluiman [mailto:subscr...@juriansluiman.nl] Sent: 06 May 2009 04:03 PM To: fw-general@lists.zend.com Subject: Re: [fw-general] Bootstrapping modules Op Wednesday 06 May 2009 14:57:00 schreef Vadim Gabriel: Hey, Are there any tutorials/guides out there that show examples on ways to bootstrap an application using more then one module? I mean if i have a directory structure like this: -library ---Zend -public ---admin -default -other ---site -default -other ---index.php -application ---configs -application.ini ---modules -admin ---controllers ---layouts -scripts ---default ---other ---views -scripts ---default ---other -helpers -site ---controllers ---layouts -scripts ---default ---other ---views -scripts ---default ---other -helpers Basically i am looking for creating a modeler structure application using ZF 1.8, Is there anything blogged about it? Thanks. Hi Vadim, I have looked into this problem as well. It isn't mentioned in the manual, but it's very simple. You should add a Bootstrap.php in each module root containing the class {ModuleName}_Bootstrap, e.g. Admin_Bootstrap, and extending it from Zend_Application_Module_Bootstrap. Now make sure you initialise the modules resource in the global bootstrap class by adding this to your application.ini (if you pass a Zend_Config object when creating the Zend_Application instance): resources.modules[] = Now you should have a proper modular design with autoloading the modules using the conventional structure. Regards, Jurian
Re: [fw-general] Bootstrapping modules
I think (but am not sure about it) you can add view helper paths in the module bootstrap. You need to specify them for each module, that's correct. But it's not much work to have an init method in each bootstrap class adding a path to the view (only some duplicated code...). -- Jurian Sluiman Soflomo.com Op Wednesday 06 May 2009 16:27:31 schreef Karl: Hi, I've been trying to configure the same setup as mentioned and was having issues trying to get my view helpers registered in the modules. You will have to register your view helper paths in each modules bootstrap file. regards, Karl _ From: Jurian Sluiman [mailto:subscr...@juriansluiman.nl] Sent: 06 May 2009 04:03 PM To: fw-general@lists.zend.com Subject: Re: [fw-general] Bootstrapping modules Op Wednesday 06 May 2009 14:57:00 schreef Vadim Gabriel: Hey, Are there any tutorials/guides out there that show examples on ways to bootstrap an application using more then one module? I mean if i have a directory structure like this: -library ---Zend -public ---admin -default -other ---site -default -other ---index.php -application ---configs -application.ini ---modules -admin ---controllers ---layouts -scripts ---default ---other ---views -scripts ---default ---other -helpers -site ---controllers ---layouts -scripts ---default ---other ---views -scripts ---default ---other -helpers Basically i am looking for creating a modeler structure application using ZF 1.8, Is there anything blogged about it? Thanks. Hi Vadim, I have looked into this problem as well. It isn't mentioned in the manual, but it's very simple. You should add a Bootstrap.php in each module root containing the class {ModuleName}_Bootstrap, e.g. Admin_Bootstrap, and extending it from Zend_Application_Module_Bootstrap. Now make sure you initialise the modules resource in the global bootstrap class by adding this to your application.ini (if you pass a Zend_Config object when creating the Zend_Application instance): resources.modules[] = Now you should have a proper modular design with autoloading the modules using the conventional structure. Regards, Jurian
Re: [fw-general] Bootstrapping modules
Thanks everyone, I think since there are so many people wondering about it, A blog post/tutorial will be a good idea *hint Matthew hint* i will take a look at those once i am at the office tomorrow. Vince. On Wed, May 6, 2009 at 5:33 PM, Jurian Sluiman subscr...@juriansluiman.nlwrote: I think (but am not sure about it) you can add view helper paths in the module bootstrap. You need to specify them for each module, that's correct. But it's not much work to have an init method in each bootstrap class adding a path to the view (only some duplicated code...). -- Jurian Sluiman Soflomo.com Op Wednesday 06 May 2009 16:27:31 schreef Karl: Hi, I've been trying to configure the same setup as mentioned and was having issues trying to get my view helpers registered in the modules. You will have to register your view helper paths in each modules bootstrap file. regards, Karl _ From: Jurian Sluiman [mailto:subscr...@juriansluiman.nl] Sent: 06 May 2009 04:03 PM To: fw-general@lists.zend.com Subject: Re: [fw-general] Bootstrapping modules Op Wednesday 06 May 2009 14:57:00 schreef Vadim Gabriel: Hey, Are there any tutorials/guides out there that show examples on ways to bootstrap an application using more then one module? I mean if i have a directory structure like this: -library ---Zend -public ---admin -default -other ---site -default -other ---index.php -application ---configs -application.ini ---modules -admin ---controllers ---layouts -scripts ---default ---other ---views -scripts ---default ---other -helpers -site ---controllers ---layouts -scripts ---default ---other ---views -scripts ---default ---other -helpers Basically i am looking for creating a modeler structure application using ZF 1.8, Is there anything blogged about it? Thanks. Hi Vadim, I have looked into this problem as well. It isn't mentioned in the manual, but it's very simple. You should add a Bootstrap.php in each module root containing the class {ModuleName}_Bootstrap, e.g. Admin_Bootstrap, and extending it from Zend_Application_Module_Bootstrap. Now make sure you initialise the modules resource in the global bootstrap class by adding this to your application.ini (if you pass a Zend_Config object when creating the Zend_Application instance): resources.modules[] = Now you should have a proper modular design with autoloading the modules using the conventional structure. Regards, Jurian -- Vincent Gabriel. Lead Developer, Senior Support. Zend Certified Engineer. Zend Framework Certified Engineer. -- http://www.vadimg.co.il/
Re: [fw-general] Bootstrapping modules
P.S I do not use the Zend_Tool yet since it doesn't support modules...Yet (as far as i know) On Wed, May 6, 2009 at 6:23 PM, Vadim Gabriel vadim...@gmail.com wrote: Thanks everyone, I think since there are so many people wondering about it, A blog post/tutorial will be a good idea *hint Matthew hint* i will take a look at those once i am at the office tomorrow. Vince. On Wed, May 6, 2009 at 5:33 PM, Jurian Sluiman subscr...@juriansluiman.nl wrote: I think (but am not sure about it) you can add view helper paths in the module bootstrap. You need to specify them for each module, that's correct. But it's not much work to have an init method in each bootstrap class adding a path to the view (only some duplicated code...). -- Jurian Sluiman Soflomo.com Op Wednesday 06 May 2009 16:27:31 schreef Karl: Hi, I've been trying to configure the same setup as mentioned and was having issues trying to get my view helpers registered in the modules. You will have to register your view helper paths in each modules bootstrap file. regards, Karl _ From: Jurian Sluiman [mailto:subscr...@juriansluiman.nl] Sent: 06 May 2009 04:03 PM To: fw-general@lists.zend.com Subject: Re: [fw-general] Bootstrapping modules Op Wednesday 06 May 2009 14:57:00 schreef Vadim Gabriel: Hey, Are there any tutorials/guides out there that show examples on ways to bootstrap an application using more then one module? I mean if i have a directory structure like this: -library ---Zend -public ---admin -default -other ---site -default -other ---index.php -application ---configs -application.ini ---modules -admin ---controllers ---layouts -scripts ---default ---other ---views -scripts ---default ---other -helpers -site ---controllers ---layouts -scripts ---default ---other ---views -scripts ---default ---other -helpers Basically i am looking for creating a modeler structure application using ZF 1.8, Is there anything blogged about it? Thanks. Hi Vadim, I have looked into this problem as well. It isn't mentioned in the manual, but it's very simple. You should add a Bootstrap.php in each module root containing the class {ModuleName}_Bootstrap, e.g. Admin_Bootstrap, and extending it from Zend_Application_Module_Bootstrap. Now make sure you initialise the modules resource in the global bootstrap class by adding this to your application.ini (if you pass a Zend_Config object when creating the Zend_Application instance): resources.modules[] = Now you should have a proper modular design with autoloading the modules using the conventional structure. Regards, Jurian -- Vincent Gabriel. Lead Developer, Senior Support. Zend Certified Engineer. Zend Framework Certified Engineer. -- http://www.vadimg.co.il/ -- Vincent Gabriel. Lead Developer, Senior Support. Zend Certified Engineer. Zend Framework Certified Engineer. -- http://www.vadimg.co.il/