FirePHP for Zend Server
April 1, 2009
Posted in FirePHP, Mac, PEAR, PHP

I recently discovered Zend Server and the free Community Edition which I think is a great development. We finally have a standard platform to code against. Not so much in terms of the bundled install of PHP and apache which has been offered for a while; but rather in terms of a standard directory structure, configuration and web-based administration system. More on that later.

Better yet this PHP environment bundle is backed by Zend which means it will stay maintained and likely make it into many corporate environments. It also ships with Zend Framework and PEAR which means it has full native FirePHP support right from the start! If you need another reason it also installs nicely alongside your existing Apache/PHP install without any conflict out of the box. There is really no reason why you cannot run Zend Server in parallel to your existing setup.

I am going to walk you through how you can get FirePHP setup for ZendServer with the help of some glue code. The glue is available from the FirePHP PEAR channel and will be maintained along with FirePHP going forward. At the end of this tutorial you will have FirePHP available automatically for any Apache vhost you configure on your Zend Server.


PEAR as a distribution system for Zend Server Applications

Before we get started I want to say some things about PEAR. To me PEAR is more about the package install/management side of things than the packages of code that are in the PEAR repository. Don’t get me wrong, the PEAR (and PECL) repository have a lot of useful code but the package manager allows you to install any package in the pear package format from any URL.

This means you can distribute your application and libraries via PEAR which has been shipping with the default PHP install for a long time. You do not have to adhere to the PEAR coding guidelines to use the package manager. You can distribute anything you want. Not just PHP.

This feature is particularly powerful when packages are deployed into a standard environment. PHP and PEAR have their standard environments (config settings, directory structure) which can be completely customized via code deployed as a PEAR package. This allows you to run your package/application in a standard PHP environment specific to your configuration needs.

The problem is that with PEAR the buck stops there. The problem is that PEAR knows only about how to configure and install components to run PHP code. It does not know about the server environment. The reason is a lack of standardization in server software installs requiring your application to have a level of abstraction and intricate configuration and deployment tools if you want to make the installation and long-term maintenance for your application as easy and seamless as possible.

In today’s internet software environment where frequent smaller updates are becoming the norm due to significant advances in scripting languages the maintenance aspect of the software is most important. You will want to be able to push changes to your software and your software’s environment for all your clients automatically without hassle. In a way that creates NO user support for you.

You can only minimize installation and update support if the installation is transparent to the user and all new features and capabilities are gradually introduced. The introduction can be done via feature documentation in the form of text, voice, video and interactive that is triggered at regular intervals, like monthly, or introduced otherwise. All bug fixes go out unnoticed at any time.

Ok. So we have established that our PHP software must be easy to install and must update automatically. We cannot rely on the user to configure Apache for our application. Users expect software to be smarter than that these days. By the way, by users I am primarily referring to software developers using open source components in their development, production and application environments.

Zend Server allows us to realize these requirements with the help of PEAR as Zend Server represents a standard environment for not just PHP, but also Apache. You will soon be able to deploy applications to Zend Server via a simple PEAR package install. You will be able to run your application with full internet, PHP, Apache, cache, filesystem and SQLite support out of the box requiring zero configuration by the user.

Given a bit more time MySQL will be added to the list along with a simple API to create and manage databases. You now have a platform that affords you to deploy an advanced PHP-based application that is easy to maintain on your terms. Today’s online and offline browser environments via Google Gears and the like coupled with Firefox and Add-ons with full system access allow you to deploy fully hybrid client-server through-browser (XHTML) applications. Application workload is spread between the server (you control) and client (client server – Zend Server) based on a scheme that is appropriate for your application.

Installing Zend Server

You can download Zend Server from here. Install it.

I installed version 4.0.0-beta1 for Mac OSX. If you are on Linux or Windows you will need to modify my commands a bit. I have only tested this on my Mac so far. It will likely not work under Windows nor Linux yet.

Ensure command line PHP works:

cd /Applications/ZendServer/bin
./php-cli -v

I got: PHP 5.2.8 …

Ensure PEAR works:

./pear version

I got PEAR 1.7.2 …

Installing FirePHP + Glue Package

We now install FirePHP and the glue package from the FirePHP PEAR channel. The install will download some code and update the Zend Server php.ini file to bootstrap FirePHP via auto_prepend_file. It will also install a FirePHP config file to etc/firephp.ini. Before the install script can make the necessary changes we first need to update some permissions. Make sure you substitute your username.

cd /Applications/ZendServer/
sudo chown cadorn:wheel etc etc/php.ini htdocs
sudo chown -R cadorn:wheel share
cd bin/
./pear channel-discover pear.firephp.org
./pear install firephp/ZendServer-alpha
./pear run-scripts firephp/ZendServer

When you run:

./pear list -c firephp

You should get:

Installed packages, channel pear.firephp.org:
=============================================
Package     Version State
FirePHPCore 0.2.1   stable
ZendServer  0.1.3   alpha

Finally you need to restart PHP (Apache). To do that go to the Zend Server admin system at http://localhost:10081/ and click Restart PHP at the bottom.

That is it! You can now start using FirePHP.

Learning ad-hock debugging with FirePHP

Now that you have FirePHP and the glue package installed and apache is restarted you can access your local FirePHP Homepage at:

http://localhost:10088/FirePHP/

Here you will find everything you need to know about FirePHP. More Zend Server specific information will be added in time.

Keep in mind that the FirePHP server code is already included by the time your PHP files are called so you can simply start logging with fb(). No need to load the FirePHPCore class yourself.

If you run into any problems you can find help at http://www.firephp.org/HQ/Support/Community.htm under Support -> Zend Server Help.

Uninstalling

Should you decide to uninstall FirePHP from the server go through the following steps. First remove

;[org.firephp.package.ZendServer]
auto_prepend_file = /Applications/ZendServer/.../Bootstrap.php

from the bottom of etc/php.ini. Go to the Zend Server admin system at http://localhost:10081/ and click Restart PHP at the bottom.

Then run:

cd /Applications/ZendServer/
./pear uninstall firephp/ZendServer
./pear uninstall firephp/FirePHPCore
rm etc/firephp.ini
rm htdocs/FirePHP

This will be more automated in the near future.

Conclusion

If you are experimenting with Zend Server I strongly encourage you to install FirePHP right away. FirePHP is a very handy debugging tool that you will learn to rely on. Having it available to all your applications by default without fuss makes it even more appealing.

With a standard platform now available via Zend Server I will be introducing new FirePHP features that tightly integrate with the server. You will be able to easily test out all of what FirePHP has to offer instantly with zero configuration. Best of all if your daily development or production applications do not run on Zend Server you will be able to more easily install and configure FirePHP on your other servers by using the Zend Server implementation as a reference.

Please let me know what you think and what you would like to see added in future versions.

3 Comments
Jess
April 1, 2009

Hello Christoph,

A very nice article.
One comment, you wrote:
“.. I installed version 4.0.0-beta1 for Mac OSX. If you are on Linux or Windows you will need to modify my commands a bit. ”
Both the Linux and the MAC version have a file called /etc/zce.rc, if you source that file by executing:
# . /etc/zce.rc
Either in /etc/profile, ~/.bashrc or anywhere else that makes sense depending on your shell ENV, you could use the ENV var ZCE_PREFIX which will work for both Linux and MAC, regardless of whether ZendServer was installed from the MAC PKG, DEB, RPM or the generic tar ball installation for Linux, so you could execute:
# . /etc/zce.rc
# cd $ZCE_PREFIX

And be certain it works for both MAC and Linux.

Another comment is that the next ZendServer package for MAC will include PHP 5.2.9, ZF 1.7.8 and a bundled MySQL, installed onto the ZendServer tree and thus not conflicting the system’s MySQL if you have one, version 5.1.32. Thought you might be interested :)

Thanks for the nice article, it always gives me joy to see our users extending ZendServer.

April 1, 2009

Thanks for the tips Jess. I’ll be incorporating your suggestions and releasing a new version ASAP.

I have some other questions about how to extend Zend Server more elegantly. I have posted a topic at: http://forums.zend.com/viewtopic.php?f=44&t=325&start=0

Jess Portnoy
April 2, 2009

Hi Christoph,

I replied to your post on forums.zend.com.

Feel free to send an email if you have additional questions :)

Comments are closed.
Linkbacks