This is part one of a series exploring modular application development in Zend Framework. In this entry we’ll look at downloading and installing Zend Framework, especially Zend_Tool, on a Linux environment. We’ll start from the beginning so that future posts can build on a known environment. Throughout this post, the code snippets are copy/paste ready, so following along should be easy, just start in a new working directory.
Install Zend Framework
The first step is to actually get ZF, so start by downloading the package (about 40MB in total) into our working directory and extracting it.
wget http://framework.zend.com/releases/ZendFramework-1.8.4/ZendFramework-1.8.4.tar.gz tar zxf ZendFramework-1.8.4.tar.gz
We’ll then create a symlink to provide an easy upgrade path (extract the new version and move the symlink), and an easier to remember directory name.
ln -s ZendFramework-1.8.4 ZendFramework
Creating an alias allows command “zf” to always point to the Zend_Tool shell script, so we can use the command line tool from wherever we need it.
Now the installation is complete, we should be able to check what version of the framework we have just installed.
zf show version # Zend Framework Version: 1.8.4
If this works, we’re ready to start creating our project. The documentation provides some alternate methods of setting up Zend_Tool, including setting it up in a windows environment.
Create the project
Once Zend_Tool is working, we can begin creating our project. For the exercise, we’ll call our project “aza” (A Zend Application). Using Zend_Tool, we create the basic structure for the project.
zf create project aza
This should produce a project structure that looks like this
[caption id=“attachment_131” align=“alignnone” width=“324” caption=“Directory Listing of new project”][/caption]
Setup the web server
Finally, we can tell the Apache2 web server about our application by adding a VirtualHost to the server configuration. You will need to replace “/WORKING/PATH/” with the absolute path to the directory in which you are working (run pwd if you’re not sure).
<VirtualHost *:80> ServerName aza DocumentRoot /WORKING/PATH/aza/public <Directory /WORKING/PATH/aza/public> php_value include_path "/WORKING/PATH/ZendFramework/library" php_value magic_quotes_gpc 0 php_value short_open_tag "on" DirectoryIndex index.php AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>
Don’t forget to restart the web server to enable the site.
Test our page!
We should now be able to navigate to our site and be warmly welcomed to our new Zend Framework application! We’ll stop here for now. In the next post, we’ll start looking at creating our first module.
2009-06-26 Updated for ZF Version 1.8.4