你在这里

Install PEAR on MAMP

主标签

In order to get PEAR working with MAMP run the following commands.

NOTE:

This may be obvious to some, but you should stop MAMP first. Otherwise you might get some strange errors.

1) Change the directory permissions so you can execute files within them:

<span class="pln">chmod </span><span class="lit">774</span><span class="pln"> </span><span class="pun">/</span><span class="typ">Applications</span><span class="pun">/</span><span class="pln">MAMP</span><span class="pun">/</span><span class="pln">bin</span><span class="pun">/</span><span class="pln">php5</span><span class="pun">.</span><span class="lit">3</span><span class="pun">/</span><span class="pln">bin</span><span class="pun">/</span><span class="pln">pear
chmod </span><span class="lit">774</span><span class="pln"> </span><span class="pun">/</span><span class="typ">Applications</span><span class="pun">/</span><span class="pln">MAMP</span><span class="pun">/</span><span class="pln">bin</span><span class="pun">/</span><span class="pln">php5</span><span class="pun">.</span><span class="lit">3</span><span class="pun">/</span><span class="pln">bin</span><span class="pun">/</span><span class="pln">php
</span>

2) Setup an alias to avoid typing the whole path.

Every time you want to access pear you have to type "/Applications/MAMP/bin/php5.3/bin/pear". Typing "pear" referes to what is installed on your mac already and not MAMP's install. (This only apply for the current session. For a more permanent alias see http://clarksco.com/?p=32)

<span class="kwd">alias</span><span class="pln"> mpear</span><span class="pun">=</span><span class="str">&quot;/Applications/MAMP/bin/php5.3/bin/pear&quot;</span>

3) Make a link between php5 and php5.3 folders:

Pear gets confused about its version because it installs in both php5.3 and php5 directory

When you upgrade pear it will create a new /Application/MAMP/bin/php5 directory and spread files between php5.3 and php5 folders. Use the code below to make a link between the two file so they act as one. More info about "ln" command. Source: @Marcelo Rodrigo's post

<span class="pln">ln </span><span class="pun">-</span><span class="pln">s php5</span><span class="pun">.</span><span class="lit">3</span><span class="pln"> php5
</span>

4) Check to make sure pear is working:

<span class="pln">mpear </span><span class="pun">-</span><span class="pln">V
</span>

5) Now upgrade pear:

<span class="pln">mpear channel</span><span class="pun">-</span><span class="pln">update pear</span><span class="pun">.</span><span class="pln">php</span><span class="pun">.</span><span class="pln">net
mpear upgrade pear
</span>

6) And check again to see if it upgraded pear correctly

<span class="pln">mpear </span><span class="pun">-</span><span class="pln">V
</span>

Install PHPUnit

Run the following commands:

1) Install PHPUnit:

NOTE: Below I am using "mpear" which is actually an alias I setup in step 2 above. You could simply use "/Applications/MAMP/bin/php5.3/bin/pear" in its place.

<span class="pln">mpear config</span><span class="pun">-</span><span class="kwd">set</span><span class="pln"> auto_discover </span><span class="lit">1</span>
<span class="pln">mpear install pear</span><span class="pun">.</span><span class="pln">phpunit</span><span class="pun">.</span><span class="pln">de</span><span class="pun">/</span><span class="typ">PHPUnit</span>

Source: http://www.phpunit.de/manual/current/en/installation.html

2) Allow MAMP to use PHPUnit

Link your MAMP's install of phpunit with the default phpunit location.

You may have to run as sudo.

<span class="pln">ln </span><span class="pun">-</span><span class="pln">s </span><span class="pun">/</span><span class="typ">Applications</span><span class="pun">/</span><span class="pln">MAMP</span><span class="pun">/</span><span class="pln">bin</span><span class="pun">/</span><span class="pln">php5</span><span class="pun">/</span><span class="pln">bin</span><span class="pun">/</span><span class="pln">phpunit </span><span class="pun">/</span><span class="pln">usr</span><span class="pun">/</span><span class="kwd">local</span><span class="pun">/</span><span class="pln">bin</span><span class="pun">/</span><span class="pln">phpunit
</span>

3) Make sure it works

<span class="pln">phpunit </span><span class="pun">--</span><span class="pln">version
</span>

For details about installing phpunit check out:


Sources:

猜你喜欢