Using PEAR to keep Zend Framework current in Zend Server CE
August 15th, 2009
Let me preface this by saying that up until recently, I’ve been anti-Zend-Server for a somewhat silly reason. I’m used to deploying PHP applications on custom compiled builds of PHP, MySQL and PHP, and the thought of not compiling my stack from source was just unbearable. For some unknown reason, I decided to give Zend Server CE another try. I’ve been in the beta program for this product since the days when it was called Zend Zenith. Back then, I couldn’t figure out why they weren’t doing a more XAMPP-style application, but I’ve since come to appreciate the the way Zend Server is set up.
Now, on to the more important bits, at least as far as I’m concerned. I like Zend Framework. I like it quite a bit. What I don’t like is continually downloading numerous copies of it as the version numbers increase. What I like even less is “pinning” applications to certain versions of ZF by using an SVN:External or similar technique. What I do like is the Zend Framework PEAR channel that Ralph Schindler makes available on zfcampus.org. This allows me to have ZF downloaded, installed, and upgraded with one command, and because it’s installed as part of PEAR, the include paths just work without extra setup.
Zend Server comes with a “fixed” version of Zend Framework (the most current package comes with 1.9.0), and my goal was to take out the version it comes with and replace it with a PEAR-installed version. I also wanted the Zend Server web application to still understand and report the correct version information for Zend Framework. As Zend Server’s GUI is really just another ZF application, it was fairly straight forward to do a littler reverse-engineering, and the whole process took less than 10 minutes to complete.
The steps outlined below should work on Mac and Linux. I doubt they would have any hope of working on Windows, as it required a symlink to trick Zend Server (in the future, I’m referring to this as ZS) into using a different copy of ZF. You could do this on Windows fairly easily still, but you’d probably need to edit one of the controllers for the ZS management GUI. Also, the some of the commands below assume you have /usr/local/zend/bin on your PATH, which I do. If you don’t, you may be talking to the wrong PHP, especially on a Mac, so I’d recommend doing that first.
The first step was to find out where ZS keeps its copy of ZF. Conveniently, the GUI reports this in the “Server Info” screen as /usr/local/zend/share/ZendFramework.
Next, we need to actually install the zfcampus.org PEAR channel and download ZF. As of this writing, the channel is serving up ZF 1.9.1, and ZS comes with 1.9.0.
1 2 3 4 5 6 7 8 9 10 11 | deeporange:~ josh$ sudo pear channel-discover pear.zfcampus.org Adding Channel "pear.zfcampus.org" succeeded Discovery of channel "pear.zfcampus.org" succeeded deeporange:~ josh$ deeporange:~ josh$ sudo pear install zfcampus/zf downloading ZF-1.9.1.tgz ... Starting to download ZF-1.9.1.tgz (3,272,570 bytes) .............................done: 3,272,570 bytes install ok: channel://pear.zfcampus.org/ZF-1.9.1 deeporange:~ josh$ |
Through a little casual directory snooping, we can learn that ZS has PEAR configured with a base path of /usr/local/zend/share/pear. This means that ZF was just installed to /usr/local/zend/share/pear/Zend. What we need to do now is get /usr/local/zend/share/ZendFramework/library/Zend (this is the path where ZS expects ZF to be) to really point to /usr/local/zend/share/pear/Zend. On a Mac or Linux system, it’s simple enough to completely remove the ZS default ZF and create a symlink to our new install.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | deeporange:~ josh$ cd /usr/local/zend/share deeporange:share josh$ sudo rm -fR ZendFramework/ deeporange:share josh$ mkdir ZendFramework deeporange:share josh$ sudo mkdir ZendFramework deeporange:share josh$ sudo mkdir ZendFramework/library deeporange:share josh$ cd ZendFramework/library/ deeporange:library josh$ sudo ln -s /usr/local/zend/share/pear/Zend . deeporange:library josh$ ls -la total 8 drwxr-xr-x 3 root wheel 102 Aug 15 14:21 . drwxr-xr-x 3 root wheel 102 Aug 15 14:21 .. lrwxr-xr-x 1 root wheel 31 Aug 15 14:21 Zend -> /usr/local/zend/share/pear/Zend deeporange:library josh$ |
Now we can see by refreshing the Zend Server GUI screen that our Zend Framework version number is reported as 1.9.1. An optional last step would be to modify the include path directive using the ZS admin screen to remove /usr/local/zend/share/ZendFramework, as this is merely a symlink to the PEAR base path at this point, which is already included in the include path. Your new include path setting should look like the one below.
Now, the next time there is a new version of Zend Framework available on zfcampus.org, all you have to do to get everything upgraded is run the following command:
1 | deeporange:! josh$ pear upgrade zfcampus/zf |


