Installing Zend Framework on Ubuntu (Hardy)

As of the 8.04 Hardy release of Ubuntu, Zend Framework has been added to the repositories, so you can install it by simply running:

sudo apt-get install zend-framework

The package installs 17M of files into /usr/share/php/libzend-framework-php/.

Once that has finished, you then need to ensure that the framework is in your PHP include path. The best way to do this is to add the include to your PHP scripts directly, or better still via a global include file. The line you would need to add is:

set_include_path(get_include_path().PATH_SEPARATOR.'/usr/share/php/libzend-framework-php');

An example project would then look like:

set_include_path(get_include_path().PATH_SEPARATOR.'/usr/share/php/libzend-framework-php');
require_once 'Zend/Mail.php';
$mail = new Zend_Mail();
$mail->setBodyText('My Nice Test Text');
$mail->setBodyHtml('My Nice Test Text');
$mail->setFrom('[email protected]', 'Mr Example');
$mail->addTo('[email protected]', 'Mr Test');
$mail->setSubject('TestSubject');
$mail->send();

As Andy pointed out in a comment, Zend Framework is evolving quite rapidly, so if the Ubuntu repository version fails to meet your needs, then you could easily install and switch to a newer version for certain projects if you modify the include path this way.

5 thoughts on “Installing Zend Framework on Ubuntu (Hardy)”

  1. I’m not exactly keen on Zend’s idea of putting the framework on ubuntu’s repositories, as its essentially a repository in itself, with its own release schedule.

    Whilst boosting the framework’s reach, it also means that new releases of Zend’s wont be accessable via the Ubuntu repo’s till the next Ubuntu release.

    The framework is still relatively new, and new ideas are continually being added, which will be missed unless getting it via Zends website. Downloading it via subversion would be more ideal.

    I wouldn’t recomend putting the include path in an ini file, that’ll override any other default include paths e.g. pear

    I’d put in a global php include file for your scripts:

    <?
    set_include_path(
    get_include_path().PATH_SEPARATOR.
    ‘/usr/share/php/libzend-framework-php’);

  2. You\’re quite right Andy… my bad! I thought for some reason that my include path statement would append this path to the existing include paths, but of course it doesn\’t. It\’s much better to include in a per project global as you\’ve suggested. I\’ll update this post accordingly!

  3. Ubuntu has a very old version (1.5.1). I think you’re probably better off downloading it yourself from zend.com.

  4. Hey!
    I’m a n00b in this situation ^^
    But my question is!
    Where I can find the file we need insert the “include path”?

    thanks

Leave a Reply

Your email address will not be published. Required fields are marked *