Lizard
Lizard

Reputation: 44992

Installing PEAR and PHPUnit with xampp

I am trying to get PHPUnit up and running the following are the steps I am currently following:

### Install new PEAR Version needed for PHPUnit 3.X
### Download:  http://pear.php.net/go-pear.phar Save it under C:\xampp\php

Open a command prompt and go to C:\xampp\php
Type "php go-pear.phar" (Installs new PEAR)
Type "pear update-channels" (updates channel definitions)
Type "pear upgrade --alldeps" (upgrades all existing packages and pear)
Type "pear channel-discover components.ez.no" (this is needed for PHPUnit)
Type "pear channel-discover pear.symfony-project.com" (also needed by PHPUnit)
Type "pear channel-discover pear.phpunit.de" (This IS phpunit)
Type "pear install --alldeps phpunit/PHPUnit" (installs PHPUnit and all dependencies)

This works up untill the point where I have to pear upgrade --alldeps after downloading all the bits it needs i get:#

ERROR: failed to mkdir C:\php\pear\data\Auth\Auth\Frontend
ERROR: failed to mkdir C:\php\pear\docs\Benchmark\doc
ERROR: failed to mkdir C:\php\pear\data\Cache\Container
ERROR: failed to mkdir C:\php\pear\docs\Cache_Lite\docs
ERROR: failed to mkdir C:\php\pear\docs\Calendar\docs\examples
ERROR: failed to mkdir C:\php\pear\docs\Config\docs
.....

My PHP directory is installed under C:\xampp\php

What do I need to change so that it knows the correct place to add these directories/ files?

Thanks

Upvotes: 25

Views: 45690

Answers (8)

nu everest
nu everest

Reputation: 10249

You cannot install PHPUnit via PEAR anymore https://stackoverflow.com/a/28457160/1783439

PHPUnit now comes as part of XAMPP. You can find it here: C:\xampp\php.

At the command prompt:

cd c:\xampp\php
phpunit

Upvotes: 0

aris
aris

Reputation: 143

this is a solution for a similar problem install propel orm in xampp. By default, pear tries install in c:\php\pear\data, and this folder don't exists, because pear is in c:\xampp\php\pear.

Show pear configutarion:

pear config-show
...
pear config-get data_dir
c:\php\pear\data

Change the pear configuration to:

pear config-set data_dir c:\xampp\php\pear\data

i hope this is useful ;)

Upvotes: 9

Sam
Sam

Reputation: 1643

This may help follow the below link: http://forum.kohanaframework.org/discussion/7346/installing-phpunit-on-windows-xampp/p1

  1. Open a command prompt and go to C:\xampp\php
  2. Type "pear update-channels" (updates channel definitions)
  3. Type "pear upgrade" (upgrades all existing packages and pear)
  4. Type "pear channel-discover components.ez.no" (this is needed for PHPUnit)
  5. Type "pear channel-discover pear.symfony-project.com" (also needed by PHPUnit)
  6. Type "pear channel-discover pear.phpunit.de" (This IS phpunit)
  7. Type "pear install --alldeps phpunit/PHPUnit" (installs PHPUnit and all dependencies)

Upvotes: 3

Jean-Pierre Schnyder
Jean-Pierre Schnyder

Reputation: 1934

If you are on Widows 8, make sure you opened a command window as administrator, otherwise dir creation will be silently rejected by the OS !

Upvotes: 5

Daniel Miladinov
Daniel Miladinov

Reputation: 1592

I was able to get pear (and subsequently, phpunit) working by creating a symlink in C:\ that points to the xamp php installation directory. That makes everything that expects php to be in C:\php happy, while not breaking anything that expected php to be in xampp:

In cmd.exe, I typed:

C:\Windows>cd \
C:\>junction php C:\path\to\xampp\php

I updated my php.ini to use C:\php as the location for php. I then installed pear (as a local installation, not system). Once pear was installed, installing phpunit was simple:

C:\>pear channel-discover components.ez.no
C:\>pear channel-discover pear.phpunit.de
C:\>pear channel-discover pear.symfony-project.com

And then finally,

C:\>pear install --alldeps phpunit/PHPUnit

Upvotes: 3

SunnyRed
SunnyRed

Reputation: 3545

You might want to add

This results in

php go-pear.phar
pear clear-cache 
pear update-channels
pear upgrade --alldeps -f 
pear channel-discover pear.phpunit.de
pear channel-discover pear.symfony-project.com
pear channel-discover components.ez.no
pear config-set preferred_state beta
pear install --onlyreqdeps phpunit/PHPUnit

Upvotes: 2

edorian
edorian

Reputation: 38961

It seems the issue is not with PHPUnit but with your pear installation in general.

The user you run the install with does not have the privileges to create the needed folders.

Ether fix those permissions or start the cmd prompt with admin privileges (windowsbutton & enter "cmd" then strg+shift+enter) and rerun the commands.

Upvotes: 25

Alphonse
Alphonse

Reputation: 301

To install in D:\xampp\php, set the following directory paths using pear config-set command

D:
cd D:\xampp\php
pear config-set doc_dir d:\xampp\php\pear\docs
pear config-set cfg_dir d:\xampp\php\pear\cfg
pear config-set data_dir d:\xampp\php\pear\data
pear config-set cache_dir d:\xampp\php\pear\cache
pear config-set download_dir d:\xampp\php\pear\download
pear config-set temp_dir d:\xampp\php\pear\temp
pear config-set test_dir d:\xampp\php\pear\tests
pear config-set www_dir d:\xampp\php\pear\www

Upvotes: 30

Related Questions