本文介绍了在MAMP 2.1.3(Mountain Lion)上安装PHPUnit的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为这个问题而苦苦挣扎.这是我尝试过的:

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

但是似乎没有任何帮助.

But nothing seems to help.

有什么主意吗?

推荐答案

我建议使用 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"
    }
}

您可以稍后根据需要对其进行调整.如果您想利用作曲家的自动加载器(我建议这样做),则可能需要配置自动加载.

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 19:28