在 MAMP 2.1.3 (Mountain Lion) 上安装 PHPUnit [英] Installing PHPUnit on MAMP 2.1.3 (Mountain Lion)
问题描述
我正在努力解决这个问题.这是我尝试过的:
I'm struggling with this issue. Here's what I've tried :
$ cd /Applications/MAMP/bin/php/php5.4.10/bin/
$ sudo ./pear channel-update pear.php.net
$ sudo ./pear upgrade pear
$ sudo /Applications/MAMP/bin/php/php5.4.10/bin/pear channel-discover pear.phpunit.de
$ sudo /Applications/MAMP/bin/php/php5.4.10/bin/pear channel-discover pear.symfony-project.com
$ sudo /Applications/MAMP/bin/php/php5.4.10/bin/pear install phpunit/PHPUnit
所以看起来可以,但是phpunit实际上是安装在
So it seems to work, but phpunit is actually installed in
/Applications/MAMP/bin/php3/bin/
如果我试图从那里启动它,它就不起作用(没有输出,没有日志).如果我将它移动到 php 5.4.10 文件夹,它仍然不起作用.
If I tried to launch it from there, it doesn't work (no output, no log). If I move it to the php 5.4.10 folder, it still doesn't work.
我已经用 MAMP 替换了 Mac OS php cli:
I've replaced the Mac OS php cli with MAMP's :
$ which php
/Applications/MAMP/bin/php/php5.4.10/bin/php
根据某些网站的建议,我也尝试删除
As suggested on some website, I've also tried to remove
/Applications/MAMP/bin/php/php5.4.10/conf/pear.conf
但似乎没有任何帮助.
有什么想法吗?
推荐答案
我推荐使用 composer.它正在成为一种标准.
I'd recommend using composer. It's becoming a standard.
首先,首先进入项目的根目录并在其中创建一个 composer.json
文件:
To start with, go to your project's root directory first and create a composer.json
file there:
{
"require-dev": {
"phpunit/phpunit": "*"
},
"autoload": {
"psr-0": {"": "src"}
},
"config": {
"bin-dir": "bin"
}
}
您可以稍后根据需要对其进行调整.如果您想利用 composer 的自动加载器(我推荐),您可能需要配置自动加载.
You can tune it to your needs later. You'll probably want to configure the autoloading if you'd like to leverage composer's autoloader (which I recomend).
接下来下载作曲家:
curl -sS https://getcomposer.org/installer | php
上面的脚本不仅会下载它,还会验证你的环境是否适合运行composer二进制文件.
The above script will not only download it but also verify your environment if it's suitable to run composer binary.
如果一切顺利,请安装您的依赖项:
If everything goes well install your dependencies:
./composer.phar install --dev
PHPUnit 二进制文件将安装在 bin 目录中(在 composer.json
中配置):
PHPUnit binary will be installed in the bin directory (configured in composer.json
):
./bin/phpunit --version
这篇关于在 MAMP 2.1.3 (Mountain Lion) 上安装 PHPUnit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!