Introduction to Zend Framework 2
If you are new to the Zend Framework, it might be a bit overwhelming to get started. The good news is that Zend has now released a new version, Zend Framework 2, which means you will not have to worry about converting what you know. Most of it will not apply anyways, as Zend is now taking a new approach with the framework’s setup.
The first thing you will notice that is different about ZF1 and ZF2 is how to install and set up an application. With ZF1, you would typically download the files to a directory on your server (MAMP or WAMP) and set your PHP include path (php.ini) to reference the ZF library. This will keep you from having to download the entire framework for each project. With ZF2, there is a huge emphasis on Composer. If you are unfamiliar with Composer, it is a package/dependency manager for PHP that Zend uses to install the necessary libraries for your project. Once Composer has set up a new application from Zend’s skeleton application, the last step is configuring a vhost for your project. Once that is complete, you are now set up with a ZF2 project.
Modules are now a big part of ZF2. From the ZF site, “Zend Framework 2 uses a module system and you organize your main application-specific code within each module”. For each different section of your site, typically you would set up a different module to handle the different functionality. For instance, if a web application has both users and albums, you would create a module for users (e.g. users/my-account) and one for albums (e.g. albums/{username}/{album_name}). This is what Zend is referring to as application specific code. There are a few key files that your module needs to have in order for it to be registered {module_name}.php and a module.config.php. These files tell Zend what to load and where to load it.
The last big difference in configuration and setup between ZF1 and ZF2 is the application configuration and routing. In ZF1, it was very easy to set up an application.ini and routes.ini file and have Zend load these settings. In ZF2, it is very different and much more complicated. It has now been split up into a module with different directories for each section (modules, DB, memcache, etc.). In order for Zend to load your modules, you will need to register your module in the module auto_loading array.
For more detailed information, with working examples, you can visit the ZF website (http://framework.zend.com/learn/).