Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

So it seems to work, but phpunit is actually installed in

/Applications/MAMP/bin/php3/bin/

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.

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.

Any idea ?

like image 331
Julien Avatar asked Dec 07 '22 08:12

Julien


1 Answers

I'd recommend using composer. It's becoming a standard.

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).

Next download the composer:

curl -sS https://getcomposer.org/installer | php

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 binary will be installed in the bin directory (configured in composer.json):

./bin/phpunit --version
like image 119
Jakub Zalas Avatar answered Jan 05 '23 20:01

Jakub Zalas