使用Composer安装PHPUNIT [英] Install PHPUNIT with Composer
问题描述
我在Symfony 2上有项目,我想在Windows 7上使用PHPUNIT.
I have project on Symfony 2 and i would like use PHPUNIT on Windows 7.
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.接下来,我尝试命令:
First i use system-wide installation but i dont know when this installed. Next i add to my composer.json require-dev. This installed phpunit in C:/wamp/www/myproject/vendor/symfony. Next i try commands:
composer install --dev
我不能使用phpunit.在cmd.exe中,我输入"phpunit",但出现错误:
And i can't use phpunit. In cmd.exe i enter "phpunit" and i have error:
'phpunit' is not recognized as an internal or external command operable program or batch file
我如何使用phpunit?我有Windows 7,Wamp服务器和php 5.4.12.
How can i use phpunit? I have Windows 7, Wamp server and php 5.4.12.
推荐答案
当您通过composer在Windows中安装PHP-Unit时,全局安装将在其中创建文件
When you install PHP-Unit in windows via composer, the global installation will create files in
C:\Users\YOUR_USERNAME\AppData\Roaming\Composer
要通过命令行轻松执行phpunit
,您需要在Windows环境变量中添加phpunit.bat
文件的路径.为此:
To execute phpunit
easily via command line you need to add path of phpunit.bat
file in windows Environment Variables. For this:
- 右键单击
My Computer
- 转到
Properties -> Advance system settings
和 - 从
Advance
选项卡中单击Environment variables
.
- Right click
My Computer
- Go to
Properties -> Advance system settings
and - Click
Environment variables
from theAdvance
tab.
现在将C:\Users\YOUR_USERNAME\AppData\Roaming\Composer\vendor\bin
添加到Windows PATH
.
Now add C:\Users\YOUR_USERNAME\AppData\Roaming\Composer\vendor\bin
to the windows PATH
.
您现在可以从命令运行phpunit.请注意,您可能需要重新启动命令提示符,以使更改生效.
You can now run the phpunit from command. Note that you may need to restart your command prompt for the changes to take effect.
这篇关于使用Composer安装PHPUNIT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!