As of phing 2.4.10 you can download phing as a phar file, perfect for using phing on servers with PHP > 5.3 but without access to PEAR. Quite new to phar files I struggled to get started, but it turns out its actually really easy! Failing to find any resources online myself, hopefully this will help somebody else.
Setting up the variables
Getting started is simple, we just have to tell phing to find itself in the phar file. On unix, 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, like so:
$ phing -h |
Automating this process
Nobody wants to type that out everytime, so just use my setup.sh script, stick it in the same directory as phing.phar and just run:
$ . ./setup.sh |
Note the double dot, this 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}" |
But just download it to wherever phing.phar is, rename it to setup.sh, chmod it and run it – it’s quicker (kinda)!