Wednesday, March 13, 2013

Install PHPUnit, PEAR in windows 7 for Zend Framework 2 Tutorial

In Order to Do ZendFramework 2 Tutorial in Windows Environment, you need to download the
Zend Skeleton Application base code, this can be done by following steps
a) Using Composer
1) Install Composer from http://getcomposer.org
2) Open command-prompt and enter following command
c:\composer create-project --repository-url="http://packages.zendframework.com" zendframework/skeleton-application c:\UniServer\www\zf2_2

b) Download the base code from https://github.com/zendframework/ZendSkeletonApplication and follow the setup guide from http://framework.zend.com/manual/2.0/en/user-guide/skeleton-application.html

To Run ZendFramework #2 tutorial with Uniform Server, we needs to setup PHPUnit.
These are the steps for PHPUnit Installation For Windows 7

The base write up was copied from (by )
http://bdhacker.wordpress.com/2012/02/18/install-phpunit-in-windows-wamp-using-pear/
and
http://bdhacker.wordpress.com/2012/02/18/installing-pear-in-windows-wamp/

Go to the directory where PHP is located.
Typically, this is \bin\php\php5.3.8
For myself, I am using UniformServer, so it is c:\UniServer\usr\local\php

We’ll call this path “PHP’s location” throughout this article.

Now, install PEAR following instructions in this tutorial.
-----------------------------------------------------------------------------------------------------------

Go to the directory where PHP is located.
Typically, this is \bin\php\php5.3.8
For myself, I am using UniformServer, so it is c:\UniServer\usr\local\php


We’ll call this path “PHP’s location” throughout this article.

    Download “go-pear.phar” from this location: pear.php.net/go-pear.phar
    Create a folder “pear” in your PHP’s location
    Put the downloaded “go-pear.phar” file in this location.

Open a command prompt with administrative privilege. For this, click on start menu, type “cmd” – you can see the cmd.exe icon.
Right-click on this icon and click “Run as administrator”

Cmd.exe will open. Go to the direcotry of your PHP’s location, by typing “cd” command. For example, my wamp is located in “D:\wamp”, so I write following command:

cd c:\Uniserver\usr\local\php

Now run the downloaded file, by typing:

php .\pear\go-pear.phar

Installation will begin! During installation, you’ll need to respond to some prompts, just hit enter/press “Y” when necessary.

After installing, double-click and instal “PEAR_ENV.reg” found in your PHP’s location.

Optionally, you can add your PHP’s location in your PATH variable.

Common Problem:
If you hit the permission problem during the above installation process while it tries to create c:\windows\pear.ini file.

In Command Prompt Type:
php .\pear\go-pear.phar
Then Select as follow:
- 1. Select "system"
- 2. type 11 and Enter, then type in your "PHP's location"(e.g. c:\Uniserver\usr\local\php )
The process will pass through successfully. And you will find pear.ini file in your "PHP's location"

Copy the pear.ini file into your windows system directory (e.g. c:\windows )

------------------------------------------------------------------------------------------------------------
Please ensure the pear installation is completed before move to next step.

Open a command-prompt, go to PHP’s location using cd, and type:

pear channel-discover components.ez.no

pear channel-discover pear.phpunit.de

pear channel-discover pear.symfony-project.com

  a) if this command failed, type: "pear channel-delete pear.symfomy-project.com" to remove the channel
  b) type: pear channel-discover pear.symfony.com
  c) type: pear install pear.symfony.com/Yaml
)

pear install --alldeps phpunit/PHPUnit

We’re done! type "phpunit –version" to confirm installation.