With the release of the 1.8 series of Zend Framework, I felt the need to update this article, especially due to the entirely new project setup process provided by Zend_Tool.
Again, we start with installing the LAMP stack if you haven’t done so already:
sudo tasksel install lamp-server
So now you’ve got your LAMP stack up and running, lets download the latest SVN tag of Zend Framework. At the time of writing, the latest stable is 1.8.1, which I’ll use here. If you want to check for the latest version, visit http://framework.zend.com/svn/framework/standard/tags/ in your browser, and the last folder is the one you want. If you want stable full releases, ignore the RC/PR versions. So, once you’ve determined the version you want, we’ll check out the release:
cd /opt
sudo mkdir ZendFramework
sudo svn co http://framework.zend.com/svn/framework/standard/tags/release-1.8.1/
It is likely you’ll need to use sudo for these commands as /opt is owned by root by default. You’ll see a big long list of files being checked out, and once that’s done you’ll have a new folder appropriately named “release-1.8.1″. Create a soft link called “current” to the release folder so you can change the default included Zend Framework version without restarting Apache in the future:
sudo ln -s release-1.8.1 current
You can stop there if you like, and manually add the include path into your PHP scripts using set_include_path. However, if you would like the current Zend Framework included automatically, then continue by opening /etc/php5/apache2/php.ini in your favourite editor. Add the path to your include_path list. For example, if your current include_path is (and this is the default):
include_path = ".:/usr/share/php5:/usr/share/pear"
Then change it to:
include_path = ".:/usr/share/php5:/usr/share/pear:/opt/ZendFramework/current/library"
All you need to do now is restart Apache:
/etc/init.d/apache2 restart
In the future, if you wish to change to a new default Zend Framework version (for example 1.8.2), then just check out the SVN directory and change the soft link. You won’t even have to restart Apache, and the changes will take effect immediately! For example:
sudo svn co http://framework.zend.com/svn/framework/standard/tags/release-1.8.2/
sudo rm current
sudo ln -s release-1.8.2 current
Now to initialise a new Zend Framework project using Zend_Tool, we need to set up paths and so on for your command line. If you haven’t already, you need to install the CLI (Command Line Interface) for PHP:
sudo apt-get install php5-cli
Once that’s installed, we need to add the Zend Framework’s bin directory to the path. First lets add the framework path to the CLI’s php.ini. Do the same php.ini modification as above but in /etc/php5/cli/php.ini.
Edit your ~/.bashrc or /etc/profile (or wherever you’d like to add the path) and add this line:
PATH=/opt/ZendFramework/current/bin:"${PATH}"
To check this is all working properly, you can:
If you see the above output, then Zend Framework is successfully setup. For more information about Zend_Tool and how to set up a new Zend Framework 1.8.x project, read the documentation.
You can keep up to date with the latest Zend software, then just subscribe to their RSS feed!