Installing PEAR and PHPUnit with xampp

為{幸葍}努か 提交于 2019-12-17 22:07:26

问题


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


回答1:


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.




回答2:


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



回答3:


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 ;)




回答4:


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 !




回答5:


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



回答6:


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)



回答7:


You might want to add

  • pear clear-cache to clear the REST/XML-RPC cache and
  • pear config-set preferred_state beta to set the preferred package state to beta

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



回答8:


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


来源:https://stackoverflow.com/questions/5801111/installing-pear-and-phpunit-with-xampp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!