Add phing script

This is a refactored version of pull #118 that was out of sync. Merging myself to avoid more issues.