Hey Rob,
great work thanks for sharing… I have noticed two minor glitches:

Module.php:
when calling getConfig() I got an Notice: Undefined variable: env
If I add it as a parameter of the function getConfig($env = null) it stops complaining.

modules/Album/views/album/index.phtml:
there is a typo $this->$this->headTitle($title); which throws an Catchable fatal error: Object of class ZendViewPhpRenderer could not be converted to string
just remove change to $this->headTitle($title);

I've found a few minor bugs.
In AlbumModelAlbums.php in getAlbum there is an Exception thrown. However Exception class doesn't exist in current namespace. To resolve this you have to add before Exception
So it becomes throw new Exception

One more thing in your pdf on page 14 under paragraph 'Listing Albums' there is a reference to file modules/Album/src/Album/IndexController
It should be AlbumController.

Hello Rob!
After going through the tutorial step by step, when testing in the browser for the second time – Album list, I get an error: "An error occurred Page not found.", but the default host/index/ controller works well and shows up. Tested by doing die()'s through every file and none of the Album files – controller/model respond, only the config files.
Could you make a guess where could be the problem? Thank you in advance!

I find typo on page 8: path to controller should not be
"modules/Album/src/Album/AlbumController.php:"
but
"modules/Album/src/Album/Controllers/AlbumController.php:"
This path is above the code of the controller.

Rob, I want to translate this document into Russian. But pdf not a very good format for editing on Linux. Do you have this text in another format?

"As you can see, we have loaded our Album module before the Application module. This convention
exists as we expect that you will install third-party modules in your application and will override their default configuration by editing the Application module’s configuration file."

This will also impact the custom routes defined in the module – IF ANY. In the current implementation module routes will be assembled but not matched. If you want the custom routes for your module to be matched then you need to put 'Album' after 'Application' in the module list, or override the routes by moving them from the Album module to the 'Application' Module.

I couldn't figure out why I was having issues getting ZF2 running. I skipped the VirtualHost step because I usually organize projects like http://my-domain/client-name/project-name/public/ while I'm in development and don't move to a virtual host until production.

I've done that for 3 years with ZF without any issues and it always handles the paths correctly, but for some reason ZF2 wouldn't run like that (always gets page not found). I eventually setup a VirtualHost and voila. Any idea how I can get it to run using the full path without having to setup a virtual host for each project?

Rob, I must not be as bright as the other folks using your tutorial. I started the Zend Framework 2 tutorial and go all the way to page 3. I tried to open the page then when I get this error. PHP Fatal error: Interface 'ZendModuleConsumerAutoloaderProvider' not found in C:vHostszf2tutorialmodulesApplicationModule.php on line 10

The only files I see are
ZendModuleManager.php
ManagerOptions.php
README.md

Can you please advise me of what I am doing wrong here? Thanks, Frank.

Just wanna correct myself from before. I originally said that the ZF2 Beta1 that was on their website was missing things like /Controller/ and that I could get it straight from Git but I now see that the Controller was moved to /mvc/ and it seems to be that way in your tutorial as well :)

Hey Rob, sorry to post many times but have a question. In your example you're injecting the DB Adapter directly into the model which is extending Zend Table. Great idea but I have about 90 tables in total. Should I be copy and pasting the injection code for each table class or is there a way to just do it once? I've tried injecting it straight into AbstractTable, tried injecting it into Table and I've tried creating a wrapper class which extends Table and then each of my tables extends this but to no success!

Firstly, many thanks for the great tutorial. I went through this and successfully set up the project.
I found some other similar tutorials and they seem to copy the way ZF 1.x used to work but I prefer this whole new better way with use of DI and events.
Only question I have is, I'm missing the custom bootstrap class I used to create with ZF1.x, where I could create methods like initDatabase() or initCache() etc and it used to execute before application runs.
Would it be possible to elaborate a little bit on that,how can we add custom initXXXX methods with bootstrap?
I'm trying to integrate Doctrine with ZF2.0 and struggling a little bit just because of this (I believe).

Thank you for the awesome book and tutorials. I was playing with zf2 and was wondering how to integrate phpunit into zf2 for module testing. How to make use of the DI for testing and what is the proper way to set up the unit testing in zf2? Thanks and looking forward to more good ones!

Hi Rob,
Just downloaded version 0.2.0 of your great tutorials. However, I saw on page 6 "Configuration) that there is no return of $default in ./module/Album/config/module.config.php Did you fix this already? I replaced $default= with return and I have part 1 of the tutorial working.

Everyone, please take care of those nested arrays. It took me hours to figure out where in the config files I missed a ')' which gives nasty errors… (yes, it was completely my bad…)

@Dominic Watson, Regarding the config used in DI injection. I agree, this seems difficult to maintain. One way to resolve this issue would be to setup the dependency injection in code instead of config.

In you module init method subscribe to the bootstrap (see applicationviewlistener as an example):

within the controller indexAction()
$this->_helper->_layout->setLayout('layout2');

This returns an error of
PHP Notice: Undefined property: TestControllerTestController::$_helper
and
PHP Fatal error: Call to a member function setLayout() on a non-object in

then I have also tried within the index.phtml
$this->layout()->setLayout('layout2');

this does not cause php errors… however it did not load the layout at all.
Upon further investigating,
$this->layout()->getLayout()
returns the correct value, but it seems to pass this after the default layout has already been loaded… ie it loads layout.phtml then changes the layout (which is too late and is ignored) then loads the content of index.phtml

they modified the renderLayout () of Listener.php to fix disabling layout
$this->getLocator()->get('view')->layout()->disableLayout();

from this i've done some fiddling and made a rudimentary fix, but I'm not very familiar ZF2 or ZF1 and there is bound to be a more efficient way.

within a controller you can now do any of the following
$this->getLocator()->get('view')->layout()->setLayout('layouts/ajax.phtml');
$this->getLocator()->get('view')->layout()->setLayout('ajax');
$this->getLocator()->get('view')->layout()->disableLayout();

within a view phtml file you can do
$this->layout()->setLayout('layouts/ajax.phtml');
$this->layout()->setLayout('ajax');
$this->layout()->disableLayout();