Easy! Unfortunately, if we try this after we’ve installed MAMP we’ll get an error as the „pear“ command can’t be found and running „php“ will point us to OS X’s default version.
2 | $echo'export PATH=/Applications/MAMP/bin/php/php5.3.6/bin:$PATH'>>~/.profile |
Now you can either restart your terminal session or run the following from your home directory to read in the new path variable.
2 | $../.profile |
You should now have the correct binaries on your path and can check this by running the „which“ command again.
2 4 6 8 10 | $pear channel-discover pear.drush.org Discovery of channel'pear.drush.org'succeeded $pear install drush/drush Starting todownload drush-4.5.0.tgz(281,392bytes) .........................................................done:281,392bytes |
Hurray! Good times.
For PECL to work we need to prepare the build environment for extensions by making the PHP source available. Download the MAMP Server components and libraries zip file and make yourself a cup of tea whilst you wait. Perhaps have a biscuit as well, I recommend the classic custard cream. You’ll also need to have Xcode installed to get Autotools.
Once it’s downloaded, find the zip file corresponding to your version of PHP, extract it into a new directory in your PHP installation and run the configure script.
2 4 6 8 10 | $pecl install uploadprogress . Build process completed successfully Installing'/Applications/MAMP/bin/php/php5.3.6/lib/php/extensions/no-debug-non-zts-20090626/uploadprogress.so' install ok:channel://pecl.php.net/uploadprogress-1.0.3.1 configuration option'php_ini'isnotset tophp.ini location You should add'extension=uploadprogress.so'tophp.ini |
You can now have some upload progress goodness by editing your php.ini file (in this case /Applications/MAMP/bin/php/php5.3.6/conf/php.ini) and restarting the MAMP servers.
The following instructions install PEAR and PECL on Mac OS X under /usr/local/. PECL is bundled with PEAR. So this is as simple as installing PEAR on Mac OS X.
PEAR is PHP's Package Repository and makes it easy to download and install PHP tools like PHPUnit and XDebug. I specifically recommend these two for every PHP developer.
You should now be at a prompt to configure PEAR.
Type 1 and press return.
Type 4 and press return.
Enter:
Press return
You should be able to type:
Eventually, if you use any extensions or applications from PEAR, you may need to update PHP's include path.
Find this interesting? Let's continue the conversation on Twitter.