簡體   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