使用xampp安装PEAR和PHPUnit

使用xampp安装PEAR和PHPUnit,php,installation,phpunit,pear,Php,Installation,Phpunit,Pear,我正在尝试启动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

我正在尝试启动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)
直到下载完所有需要的位后,我必须升级--alldeps:#

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

我需要更改什么,以便它知道添加这些目录/文件的正确位置


谢谢

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

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

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

您可能需要添加

  • pear清除缓存
    到和
  • pear config set preferred\u state beta
    设置
这导致

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

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

显示pear配置:

pear config-show
...
pear config-get data_dir
c:\php\pear\data
将pear配置更改为:

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

我希望这是有用的;)

要在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
通过在C:\中创建一个指向xamp php安装目录的文件,我能够使pear(以及随后的phpunit)工作。这让所有希望php在C:\php中出现的东西都很开心,同时又不会破坏任何希望php在xampp中出现的东西:

在cmd.exe中,我键入:

C:\Windows>cd \
C:\>junction php C:\path\to\xampp\php
我更新了php.ini,使用C:\php作为php的位置。 I然后(作为本地安装,而不是系统)。 安装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

如果您在Widows 8上,请确保打开了目录,否则操作系统将自动拒绝创建目录

这可能有助于遵循以下链接:

  • 打开命令提示符并转到C:\xampp\php
  • 键入“pear更新通道”(更新通道定义)
  • 键入“pear升级”(升级所有现有软件包和pear)
  • 键入“pear channel discover components.ez.no”(这是PHPUnit需要的)
  • 键入“pear channel discover pear.symfony project.com”(PHPUnit也需要)
  • 键入“pear channel discover pear.phpunit.de”(这是phpunit)
  • 键入“pear安装--alldeps phpunit/phpunit”(安装phpunit和所有依赖项)

  • 您不能再通过PEAR安装PHPUnit了

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

    在命令提示下:

    cd c:\xampp\php
    phpunit
    

    你知道XAMPP的全部意义,它与U盘的可移植性在那里丢失了如果你需要创建
    C:\PHP\Pear
    ,我也这么做了,尽管我讨厌与这些系统对抗。但我仍然希望看到解决方案,它将使用xampp目录,而不是一些
    C:\PHP
    ,您可以通过使用
    pear config show
    和相关命令来更改目录,看看是否可以让它工作。但是考虑到xampp和pear中的许多东西都依赖于固定路径,这将不是一件简单的事情。在某些键盘上,ctrl键是一个简单的选择。您需要添加局部变量
    PHP\u pear\u SYSCONF\u DIR
    ,谢谢您的帮助。要验证配置,首先输入pear config show(aris应答)
    cd c:\xampp\php
    phpunit