Torkil Johnsen

My personal piece of cyberspace

Installing Phing on MAMP (Mac OSX)

Posted in joomla,mac,mamp,osx,pear,phing,PHP,Web apps on Apr 6th, 2009

Just bumped into Phing, and thought I’d share my experiences. Installing Phing is easy enough. Phing is a build system in the shape of a PHP Pear package, that can do many things. To quote Hans Lillelid, this could include for instance configuring, packaging, uploading and testing. Ideal for building installable Joomla zip-files, which is what I am using it for right now.

This is how I set up Phing to run on my local MAMP-based webserver. MAMP = Apache, MySQL and PHP, on a Mac, much like WAMP and LAMP for Windows and Linux respectively.

These are just very brief instructions, specifically on how I did this on my own system. A complete documentation on Phing can be found on at phing.info. You don’t actually need MAMP either, it was just what I was working with to begin with.

Open the application Terminal. You can find pear by doing a locate call: locate pear.
Currently MAMP requires you to install it into /Applications, so you should find pear (for php5) here: /Applications/MAMP/bin/php5/bin/.
Make sure MAMP is using the correct php version, by starting MAMP and checking your preferences.

1: Go to the correct folder:
cd /Applications/MAMP/bin/php5/bin/

2: Make sure pear can locate the package:
./pear channel-discover pear.phing.info

3: Install phing:
./pear install phing/phing

Phing should now be installed. Run the command “ls -al” and you should see phing in the same folder as pear.

You can now run this command:
./phing -h
This will give you an overview of the phing’s options.

From here you can for instance just run:
./phing -f /path/to/your/build.xml

  • sylvain pham

    For launch phing anywhere, i’m trying this

    create file :
    /Applications/MAMP/bin/setenvmamp.sh :
    add this :
    PATH=/Applications/MAMP/bin/php5/bin:$PATH export PATH

    in /Users/user/.profile
    add this
    test -r /Applications/MAMP/bin/setenvmamp.sh && . /Applications/MAMP/bin/setenvmamp.sh

    close Terminal and relaunch

  • sylvain pham

    For launch phing anywhere, i’m trying this

    create file :
    /Applications/MAMP/bin/setenvmamp.sh :
    add this :
    PATH=/Applications/MAMP/bin/php5/bin:$PATH export PATH

    in /Users/user/.profile
    add this
    test -r /Applications/MAMP/bin/setenvmamp.sh && . /Applications/MAMP/bin/setenvmamp.sh

    close Terminal and relaunch

  • Peter Raeves

    Thank you for sharing your experiences.
    I’ve tried to do the same thing, including step 3: pear downloaded phing, but phing itself didn’t get installed.
    OS: 10.5.7
    MAMP: 1.7.2
    Could you give me a few pointers to troubleshoot (the manual on phing.info didn’t help me much).
    Thank you,
    Peter

  • Peter Raeves

    Thank you for sharing your experiences.
    I’ve tried to do the same thing, including step 3: pear downloaded phing, but phing itself didn’t get installed.
    OS: 10.5.7
    MAMP: 1.7.2
    Could you give me a few pointers to troubleshoot (the manual on phing.info didn’t help me much).
    Thank you,
    Peter

  • http://www.rmdstudio.com Rastin Mehr

    Thank you so much for the useful blog post. Question: do you have any tips on upgrading MAMP’s PEAR? because during the phing installation I got this:

    phing/phing requires PEAR Installer (version >= 1.8.0), installed version is 1.7.1
    phing/phing can optionally use package “phing/phingdocs” (version >= 2.4.0)
    phing/phing can optionally use package “pear/VersionControl_SVN” (version >= 0.3.2)
    phing/phing can optionally use package “channel://pear.phpunit.de/PHPUnit” (version >= 3.4.0)
    phing/phing can optionally use package “pear/PhpDocumentor” (version >= 1.4.0)
    phing/phing can optionally use package “pecl/Xdebug” (version >= 2.0.5)
    phing/phing can optionally use package “pear/PEAR_PackageFileManager” (version >= 1.5.2)
    No valid packages found

  • http://www.rmdstudio.com Rastin Mehr

    Thank you so much for the useful blog post. Question: do you have any tips on upgrading MAMP’s PEAR? because during the phing installation I got this:

    phing/phing requires PEAR Installer (version >= 1.8.0), installed version is 1.7.1
    phing/phing can optionally use package “phing/phingdocs” (version >= 2.4.0)
    phing/phing can optionally use package “pear/VersionControl_SVN” (version >= 0.3.2)
    phing/phing can optionally use package “channel://pear.phpunit.de/PHPUnit” (version >= 3.4.0)
    phing/phing can optionally use package “pear/PhpDocumentor” (version >= 1.4.0)
    phing/phing can optionally use package “pecl/Xdebug” (version >= 2.0.5)
    phing/phing can optionally use package “pear/PEAR_PackageFileManager” (version >= 1.5.2)
    No valid packages found

  • http://torkiljohnsen.com torkil

    Phing requires PEAR installer 1.8.0 or greater. Look into upgrading your MAMP installation.

  • http://torkiljohnsen.com torkil

    Phing requires PEAR installer 1.8.0 or greater. Look into upgrading your MAMP installation.

  • http://www.torkiljohnsen.com tj

    Sorry for the late response Rastin. I have been less than active on the blog…

    Could you try /Applications/MAMP/bin/php5/bin/pear upgrade-all
    ?

  • http://www.torkiljohnsen.com tj

    Sorry for the late response Rastin. I have been less than active on the blog…

    Could you try /Applications/MAMP/bin/php5/bin/pear upgrade-all
    ?

  • David Findlay

    So I’ve done this and phing works, but it runs incredibly slow. On another system it runs fast. It’s obviously something in the build environment but I don’t know what. Any suggestions?

    • David Findlay

      Ok so seems my problem was a dumbass error. I was recursively copying my entire tree, including the build dir into the build dir every time I built. So each time I ran Phing to build, my build dir got bigger. As there were more and more files to copy every time, this caused my build to take longer and longer every time it ran. It was also eating my hard drive, but I didn’t put two and two together until I looked a verbose log.


Creative Commons License
This work by Torkil Johnsen is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.