Hello World in Zend Framework 2

Posted in January 2013 by under zend-framework

It appears to be a common complaint that Zend Framework 2 is simply too complicated and that the getting started guide requires that you know tools like Git, Composer, how to set up a virtual host, PHPUnit, poedit and so on.

It is a difficult situation to resolve because on one hand the getting started tutorial needs to be just that, a guide to get you set up and working. On the other hand there is benefit in using the tools and practices that as a PHP developer you probably should know.

I see people complain that they want to learn Zend Framework and being expected to learn composer first is in some way a step too far. To be honest, if you are a developer unwilling to learn something like Composer then Zend Framework 2 is probably not going to be a good fit with how you currently work. Zend Framework 2 is all about building reusable modules and in order for this to work, you need to be working in a way consistent to how Zend Framework 2 and many other projects work. Part of that requires using the same tools as those projects and Git and Composer are two such tools.

The getting started tutorial is based on the ZendSkeletonApplication, which is a reasonable starting point. I personally find that I remove a lot of bits, such as translations and default routes before starting with the ZendSkeletonApplication, so I suspect this skeleton could be cut a little closer to the bone.

I thought perhaps writing a no fuss Hello World! application on Zend Framework 2 would be a useful alternative to the ZendSkeletonApplication for getting started. So I have written one called RjhHelloWorld and it is downloadable as a ZIP file from Github. You do not need to use Git or Composer and Zend Framework 2 is already provided in the Zip file.

You just extract the zip file somewhere and configure a virtual host to point to the public/ directory.

What I discovered in doing this, is that it provides a small codebase which runs quickly and is easy to understand, however it is not apparent how to build anything larger based on this simple application. Hopefully though it will serve as a springboard to get you started.