gpt4 book ai didi

php - 使用 Composer 安装 PHPUNIT

转载 作者:可可西里 更新时间:2023-11-01 12:36:30 25 4
gpt4 key购买 nike

我在 Symfony 2 上有一个项目,我想在 Windows 7 上使用 PHPUNIT。

On githut phpunit is:

Composer

Simply add a dependency on phpunit/phpunit to your project's composer.json file if you use Composer to manage the dependencies of your project. Here is a minimal example of a composer.json file that just defines a development-time dependency on PHPUnit 3.7:

{
"require-dev": {
"phpunit/phpunit": "3.7.*"
}
}
For a system-wide installation via Composer, you can run:

composer global require 'phpunit/phpunit=3.7.*'
Make sure you have ~/.composer/vendor/bin/ in your path.

首先,我使用系统范围的安装,但我不知道何时安装。接下来我添加到我的 composer.json require-dev。这在 C:/wamp/www/myproject/vendor/symfony 中安装了 phpunit。接下来我尝试命令:

 composer install --dev

而且我不能使用 phpunit。在 cmd.exe 中,我输入“phpunit”,但出现错误:

'phpunit' is not recognized as an internal or external command operable program or batch file

我如何使用 phpunit?我有 Windows 7、Wamp 服务器和 php 5.4.12。

最佳答案

当你通过 composer 在 windows 中安装 PHP-Unit 时,全局安装将在中创建文件

C:\Users\YOUR_USERNAME\AppData\Roaming\Composer

要通过命令行轻松执行phpunit,您需要在windows 环境变量中添加phpunit.bat 文件的路径。为此:

  1. Right click My Computer
  2. Go to Properties -> Advance system settings and
  3. Click Environment variables from the Advance tab.

现在将 C:\Users\YOUR_USERNAME\AppData\Roaming\Composer\vendor\bin 添加到 Windows PATH

您现在可以从命令运行 phpunit。请注意,您可能需要重新启动命令提示符才能使更改生效。

关于php - 使用 Composer 安装 PHPUNIT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18688059/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com