繁体   English   中英

使用 xampp 安装 PEAR 和 PHPUnit

[英]Installing PEAR and PHPUnit with xampp

我正在尝试启动并运行 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)

这一直有效,直到我必须在下载所需的所有位后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
.....

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

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

谢谢

要安装在 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

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

运行安装的用户没有创建所需文件夹的权限。

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

这是类似问题的解决方案,在 xampp 中安装推进 orm。 默认情况下,pear 尝试安装在 c:\php\pear\data 中,并且此文件夹不存在,因为 pear 在 c:\xampp\php\pear 中。

显示梨配置:

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

将梨配置更改为:

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

我希望这是有用的;)

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

这可能有助于遵循以下链接: http://forum.kohanaframework.org/discussion/7346/installing-phpunit-on-windows-xampp/p1

  1. 打开命令提示符和 go 到 C:\xampp\php
  2. 输入“pear update-channels”(更新频道定义)
  3. 键入“pear upgrade”(升级所有现有包和 pear)
  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 和所有依赖项)

通过在 C:\ 中创建一个指向 xamp php 安装目录的符号链接,我能够让 pear(以及随后的 phpunit)工作。 That makes everything that expects php to be in C:\php happy, while not breaking anything that expected php to be in xampp:

在 cmd.exe 中,我输入:

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

我更新了我的 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

然后最后,

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

您可能想要添加

这导致

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

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

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

在命令提示符处:

cd c:\xampp\php
phpunit

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM