php 使用 xampp 安装 PEAR 和 PHPUnit

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5801111/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 22:32:15  来源:igfitidea点击:

Installing PEAR and PHPUnit with xampp

phpinstallationphpunitpear

提问by Lizard

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

我正在尝试启动并运行 PHPUnit,以下是我目前正在遵循的步骤:

### 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 --alldepsafter downloading all the bits it needs i get:#

这一直有效,直到我pear upgrade --alldeps在下载我需要的所有位后必须这样做:#

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

我的PHP目录安装在 C:\xampp\php

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

我需要更改什么才能知道添加这些目录/文件的正确位置?

Thanks

谢谢

采纳答案by edorian

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

似乎问题不在于 PHPUnit,而在于您的pear 安装

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.

Ether 修复这些权限或使用管理员权限启动 cmd 提示符(windowsbutton& 输入“cmd”然后是strg+ shift+ enter)并重新运行命令。

回答by Alphonse

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

安装在D:\xampp\php,使用pear config-set命令设置如下目录路径

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

回答by aris

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.

这是在 xampp 中安装 propel orm 的类似问题的解决方案。pear默认尝试安装在c:\php\pear\data,这个文件夹不存在,因为pear在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 ;)

我希望这是有用的;)

回答by Jean-Pierre Schnyder

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 !

如果您使用的是 Widows 8,请确保您以管理员身份打开命令窗口,否则操作系统将静默拒绝目录创建!

回答by Sam

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

这可能有助于遵循以下链接: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)
  1. 打开命令提示符并转到 C:\xampp\php
  2. 输入“梨更新通道”(更新通道定义)
  3. 输入“梨升级”(升级所有现有的包和梨)
  4. 输入“pear channel-discover components.ez.no”(这是PHPUnit所需要的)
  5. 输入“pear channel-discover pear.symfony-project.com”(PHPUnit 也需要)
  6. 输入“pear channel-discover pear.phpunit.de”(这是phpunit)
  7. 键入“pear install --alldeps phpunit/PHPUnit”(安装 PHPUnit 和所有依赖项)

回答by Daniel Miladinov

I was able to get pear (and subsequently, phpunit) working by creating a symlinkin 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:

通过在 C:\ 中创建一个指向 xamp php 安装目录的符号链接,我能够让 pear(以及随后的 phpunit)工作。这使得所有期望 php 在 C:\php 中的东西都开心,同时不会破坏任何期望 php 在 xampp 中的东西:

In cmd.exe, I typed:

在 cmd.exe 中,我输入:

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:

我更新了我的 php.ini 以使用 C:\php 作为 php 的位置。然后我安装了 pear(作为本地安装,而不是系统)。安装 pear 后,安装 phpunit 很简单:

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

回答by SunnyRed

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

回答by nu everest

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

您不能再通过 PEAR 安装 PHPUnit https://stackoverflow.com/a/28457160/1783439

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

PHPUnit 现在是 XAMPP 的一部分。你可以在这里找到它:C:\xampp\php

At the command prompt:

在命令提示符下:

cd c:\xampp\php
phpunit