As of Phing 2.4.10, you can download Phing as a PHAR file, which is perfect for using Phing on servers with PHP > 5.3 but without access to PEAR. I struggled to get started, so hopefully this guide will help someone else.
Setting up the variables
Getting started is simple. You just need to tell Phing to find itself in the PHAR file. On Unix systems, you can run the following commands or download the script I’ve made to automate it all:
$ export PHP_COMMAND=/usr/bin/php
$ export PHING_HOME=phar:///path/to/phing.phar
$ export PHP_CLASSPATH=${PHING_HOME}/classes
$ alias phing="${PHP_COMMAND} ${PHING_HOME}"
Now you can use Phing as you would had you installed it from PEAR:
$ phing -h
Automating this process
Nobody wants to type that out every time. Use the setup.sh script below, stick it in the same directory as phing.phar
, and just run:
$ . ./setup.sh
Note: The double dot is important (or it won’t export the variables to the current bash process).
The file setup.sh
consists of:
#!/bin/bash
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
export PHP_COMMAND="/usr/bin/php"
export PHING_HOME="phar://${DIR}/phing.phar"
export PHP_CLASSPATH="${PHING_HOME}/classes"
alias phing="${PHP_COMMAND} ${PHING_HOME}"