Actually that example does work I tried it less than an hour ago and got the below code to work. This method bypasses using the bootstrap class that extends Zend_Application_Bootstrap_Bootstrap. I think that method is just example of Zend_Application's flexibility not having to use a bootstrap class. I've been banging my on the wall the last two hours trying to learn how to refactor my existing application to utilize Zend_Applications functionality and have run into problems from the start. It would be nice if the developers also wrote some quick Zend_Tool demonstration applications which would save new users of Zend Framework not to mention existing users who have no experience with Zend_Application countless hours of learning a best practice way of incorporating the module. Plus it would give the developer a chance to show how they intended the module to be used in a best practice approach. Hopefully there will be some good tutorials coming soon.
Tom Shaw [email protected] $application = new Zend_Application( APPLICATION_ENV, array( 'resources' => array( 'view' => array('View'), 'FrontController' => array( 'controllerDirectory' => APPLICATION_PATH . '/controllers', ), ), 'resourcePaths' => array( 'App_Bootstrap_Resource_View' => 'App/Bootstrap/Resource', ) ) ); -----Original Message----- From: thurting [mailto:[email protected]] Sent: Friday, May 01, 2009 7:13 PM To: [email protected] Subject: [fw-general] Zend_Application resource config issue Hi, First, thanks for 1.8 - you guys rock! Second, I took a dive in today and started playing around with Zend_Application and all the related goodies. I've run into some issues with resources and wanted to run them by you: 1. In the docs (http://framework.zend.com/manual/en/zend.application.examples.html) it states that I could config a resource using the following: $application = new Zend_Application( APPLICATION_ENV, array( 'resources' => array( 'My_Bootstrap_Resource_View' => array(), // full class name; OR 'view' => array(), // short name 'FrontController' => array( 'controllerDirectory' => APPLICATION_PATH . '/controllers', ), ), // For short names, define resource paths: 'resourcePaths = array( 'My_Bootstrap_Resource' => 'My/Bootstrap/Resource', ) ) ); Unfortunately, this doesn't seem to work. First the "resourcePaths" variable doesn't seem to do anything. I think it should be "pluginPaths", so you may want to fix that. In any case, the major issue I notice is with referencing a resource by full class name. This simply does not work, and the plugin loader will throw an exception at line 392, as the matching plugin will not be found - the reason of course being that the plugin loader appends the path prefix to the class name on line 362. So, the only solution is to use the shorthand notation (e.g. 'view'), but this can lead to problems. Take the following example: Let's say my application contains two libraries in addition to the core Zend library - let's call them Lib1 and Lib2. Now, let's say both libraries define resources named Db and View. I add both Lib1 and Lib2 to my plugin path (i.e. Lib1_Application_Resource => /library/Lib1/Application/Resource and Lib2_Application_Resource => /library/Lib1/Application/Resource), with Lib2 being added last and therefore checked first when the plugin loader runs. Now, in my config I can't use full class name notation, so when I set up these resources I have to write something like: resources.db = resources.view = Here is the problem ... let's say I want to use the Lib1 Db resource and the Lib2 View resource ... how can I do this? Since I'm locked into the shorthand notation, it seems that because Lib2 will be the first path checked by the plugin loader, I'm stuck having to use both the Lib2 Db and Lib2 View resources. I guess I could create wrappers in the form of Lib3, but that seems like a pain and isn't really flexible if I want to be able to mix and match based on app environment or other cases. In addition I could create _init* methods in the bootstrap that explicitly instantiate resource instances, but I would lose the ease of use of the Application config and would have to make sure to properly set up the resource as is done in pluginResource section of the _executeResource method in Application/Bootstrap/BootstrapAbstract.php. Sorry for the mouthful. Any input? -- View this message in context: http://www.nabble.com/Zend_Application-resource-config-issue-tp23341727p2334 1727.html Sent from the Zend Framework mailing list archive at Nabble.com.
