Installation Wiki

Installing Software for Zend Framework

From InstallationWiki

Jump to: navigation, search
Installing Software for Zend Framework
Official Page
Project Documentation
Download
Source Book
200px-1847194222.jpg
ISBN 978-1-847194-22-0
Publisher Packt Publishing
Author(s) Keith Pope

In the tutorial we use various supporting software tools to help work with the Zend Framework, these tools help us maintain, test, and debug our applications. In this tutorial, we look at how to install these tools on various platforms.

Contents

[edit] Installing PHPUnit

The tutorial's examples use PHPUnit for testing. You will need PHPUnit installed to run these tests. PHPUnit can be installed using PHP's PEAR interface and using the following commands:

pear channel-discover pear.phpunit.de pear 
install -alldeps phpunit/PHPUnit

Running this command will automatically install PHPUnit for you. The version used in the tutorial is 3.3.6 although later 3.x versions should also work. You can find more information about PHPUnit at http://www.phpunit.de.

To test your installation, you should be able to run the tests included in one of the example packages using:

cd tests
phpunit AllTests.php
PHP memory limit

You may need to increase the memory limit of PHP to install PHPUnit and run the tests. This can be done by editing the php.ini and changing the memory_limit directive. Typically, I use between 64M and 128M.


[edit] Installing Xdebug

Xdebug is a PHP extension that helps with the debugging of PHP applications.The reason we use it in the tutorial examples is mainly for its code coverage analysis,which is used by PHPUnit to produce various metrics for us. If you have not already come across Xdebug, then I would strongly advise installing it, as it has many great features for debugging and profiling your applications.The installation of Xdebug can be a bit troublesome sometimes, especially on Windows systems, as you need to compile the extension.

[edit] Windows installation

Luckily for Windows, there are precompiled Xdebug modules available on the Xdebug home page at http://www.xdebug.org. If you are on Windows,I suggest downloading the correct dll for your PHP version and dropping it in your extensions directory.

[edit] Linux based installation

On any Linux system, the compilation of the extension can be done through the PECL interface. To install, run the following from your shell:

pecl install Xdebug

Hopefully, this will download, compile, and install the extension for you. If not, then you may need to download it and compile it manually. For more information on compiling Xdebug, go to http://www.xdebug.org/docs/install.

[edit] OSX Installation

OSX installation can be somewhat troublesome; if you are using the Macports version of PHP you can easily install it using the ports command using:

sudo port install php5-xdebug

If you are using MAMP, the best way to get the Xdebug binary is to download the precompiled one from the ActiveState website, http://aspn.activestate. com/ASPN/Downloads/Komodo/RemoteDebugging. Select the correct PHP Remote Debugging package for your system and then copy the xdebug.so file for your PHP version to:

/Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-
20050922/xdebug.so

Also, if you have fully configured PHP on your OSX system you should be able to use the pecl command like on Linux. However, this is not possible on a default OSX install.

[edit] Configuration

Once you have the module installed, you need to activate it in your php.ini. Edit your php.ini and add the following at the bottom:

For Windows:

zend_extension_ts="c:/php/modules/php_xdebug-4.4.1-2.0.2.dll"

For Linux:

zend_extension="/usr/local/php/modules/xdebug.so"

Remember, you need to change the path and version numbers to match your environment settings!

[edit] Installing Apache Ant

We use Apache Ant to automate some tasks that configure the application. This is not essential, but I use this on all my projects and so thought to include it as I personally find it very useful. There are other alternatives such as Phing

(http://phing.info). You can use either, but all the examples in this tutorial have used Ant.

To run Ant, you will need the Java Runtime installed and the Java JDK 6. It is best to get the Sun version from http://java.sun.com/javase/downloads/index.jsp. Once you have that installed it, you can download Ant from http://ant.apache. org/bindownload.cgi. Get the latest version 1.6.

[edit] Windows installation

Unpack the downloaded Ant package to C:\ant.

Once the package has been extracted, we need to set some environment variable so that we can run Ant from the command line and so that Ant knows where Java is located.

Open: My Computer | Advanced System Properties | Environment

Variables.

Then add the following variables:

  • ANT_HOME C:\ant
  • JAVA_HOME C:\java\bin

You may already have the JAVA_HOME variable set. If so, then leave it as it is. Also remember to change the JAVA_HOME path given above to match your system's Java bin directory.

We then need to edit the PATH variable and add the path to the Ant bin directory. We do this by adding the following to the end of the PATH string:

; C:\ant

We should now be able to open the command prompt and run the Ant command.

[edit] Linux installation

As Ant is widely used, you should be able to install it through any of the distributions package managers such as apt-get or yum. So you should be able to run something like:

apt-get install ant

On Linux, it is important to make sure that you are using the Sun version of Java and that the JAVA_HOME and ANT_HOME environment variables are set. These should be set by your package manager anyway.

[edit] Source

The source of this content is Appendix: Installing Software for Zend Framework of Zend Framework 1.8 Web Application Development by Keith Pope (Packt Publishing, 2009).

Personal tools