Before I continue this series I thought I would discuss Zend Tool. This came about when Matthew Setter who has an excellent blog on Zend Framework at Master Zend Framework tweeted me after I wrote ‘Hello World Part 1‘ and asked if I ever use the Zend Tool. Though I don’t use it as I have my own coding style which I like to have in all my applications, I can see how it can be useful as with the ‘Hello World’ series I could of done this in one part with a few lines of code. So with that in this article I will show you how to install the Zend Tool and create your first app with it. This tutorial should be good for Linux and Mac.

In ‘Installing Zend Framework‘ we made a ‘public’ folder change to that directory by cd ~/public.

Install Zend Tool

Now we have to install the Zend Tool by (if you haven’t installed Composer see ‘Installing Zend Framework’)

This will now install the Zend Tool in our ‘public’ folder but before we can use it we need to add ‘zend-log’ to the required libraries as Zend Tool will break with it so edit the ‘~/public/composer.json’ to look like:

Then update composer with composer update.

Now if we run ~/public/vendor/bin/zf.php we should get

Because we don’t want to type ~/public/vendor/bin/zf.php all the time we want to use Zend Tool lets make an alias. So in ‘~/.bash_profile’ file on Mac or ‘~/.bash_aliases’ file on Ubuntu Linux add this line:

and then in the terminal type source ~/.bash_profile or source ~/.bash_aliases to active our alias.

Create A Zend Framework Project

Now with that done lets create our new application so in our ‘public’ folder type zftool create project zf2-tutorial if ‘zf2-tutorial’ folder also ready exists then use a different one. Once the the Zend Tool has finished cd into our newly created project cd zf2-tutorial since we have just downloaded the Zend Framework Skeleton Application we will need to install all our dependentcies so in our new app folder we type composer install. And that’s it!

To prove we have installed our app navigate to it’s ‘public’ folder and type php -S localhost:8080 ./index.php to start the PHP test server and in a browser navigate to ‘localhost:8080’, you should now see:

zf2-skeleton-application
Now we can use Zend Tool to create our modules, controllers and actions. I will include how to do this in my next article.

Enjoy and love to here your thoughts.

Shaun

  • Hi Shaun, very kind of you with regards to your comments about the Master Zend Framework blog.