【问题标题】:How to configure PhpUnit in Xampp?如何在 Xampp 中配置 PhpUnit?
【发布时间】:2026-01-04 16:50:02
【问题描述】:

我已经在 Xampp 中成功安装了 PhpUnit,现在我需要配置它,我需要从文档中执行以下步骤:

2. Prepare the phpunit script:
   1.
      Rename the phpunit.php script to phpunit.
   2.
      Replace the @php_bin@ string in it with the path to your PHP command-line interpreter (usually /usr/bin/php).
   3.
      Copy it to a directory that is in your path and make it executable (chmod +x phpunit).


3. Prepare the PHPUnit/Util/PHP.php script:
   1.
      Replace the @php_bin@ string in it with the path to your PHP command-line interpreter (usually /usr/bin/php).

我在 PEAR 目录中找不到 phpunit.php。关于这个文件在 PhpUnit 的 Xampp 安装中在哪里的任何线索?有什么线索吗?

最好的问候,


更新1:

我已经通过 PEAR 安装了它。好的,我会看看这是否有效。

最好的问候,

【问题讨论】:

  • 从您的其他问题来看,我认为它有效吗?还是您遇到了另一个问题? :)

标签: php installation phpunit xampp


【解决方案1】:

我尝试对安装 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

祝你好运, 晴天

【讨论】:

    【解决方案2】:

    你是怎么安装的?如果您使用 Xampp 附带的 pear 安装程序,它应该可以正常工作。

    /opt/lampp/bin/pear channel-discover pear.phpunit.de
    /opt/lampp/bin/pear install phpunit/PHPUnit
    

    然后可执行文件应该驻留在 /opt/lampp/bin/phpunit 中。

    如果您以其他方式安装它(处理文件?,对不起,我在 xampp 文档中没有找到其他提示),那么只需指向它,我将编辑答案

    【讨论】: