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:
zf.sh show version
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!
June 6th, 2009 at 9:18 pm
good article . thanx
June 10th, 2009 at 3:55 pm
million thx
June 14th, 2009 at 1:54 am
I am using Ubuntu 9.04.I followed the steps carefully. I did not work for me.
@Mx-laptop:/opt$ ls
Adobe current release-1.8.1 ZendFramework
Above is what my opt directory is looking like.
I have php-client already installed and I have edited the .ini files
I think my problem is from editing my bashrc files. I added PATH=/opt/ZendFramework/current/bin:”${PATH}” in the second line of /etc/profile. Can you tell me what I am doing wrong.
Mx
June 14th, 2009 at 1:22 pm
Hi Mx, make sure you log out and log back in first!
Can you run /opt/ZendFramework/current/bin/zf.sh ?
December 17th, 2009 at 7:46 pm
Hi, I followed the instructions but I do not have a ‘/usr/share/pear’ folder. Can you help?
Best wishes
Peter Jones
(Please email back)
December 17th, 2009 at 8:21 pm
Hi Peter, you didn’t read carefully enough – the path I gave was just an example. You need to add the ZF path to your include_path in php.ini, I wouldn’t advise replacing the path with my path as yours will probably be different!
Sorry, but I don’t have time to e-mail people back.
July 4th, 2010 at 11:34 am
Thanks so much, just what i was looking for.
I didn’t want to bound by the repositories so i choose this way but instead of svn’s.
I downloaded it directly from their website but it is the same think i guess.
Pretty explanatory. Thanks again.
February 15th, 2011 at 4:22 am
@Mx, you technically do not have to logout and log back in, you can “execute” your bashrc file using the dot slash dot bashrc(or whatever your bash file is) thus:
./.bashrc and it will re-initialise your settings allowing you to… in effect log out and logback in.
My understanding could be incorrect, but it works.