Pro PHP- Patterns, Frameworks, Testing and More

(vip2019) #1
CHAPTER 8 ■ TESTING, DEPLOYMENT, AND CONTINUOUS INTEGRATION^115

Phing for Deployment


Phing (a recursive acronym, for Phing Is Not GNU make) is a way of automating the deploy-
ment of your PHP applications. It lets you run unit tests in an automated manner and perform
common tasks like copying files between folders.

Installing Phing


First, you need to install Phing, which you can do through PEAR:

> pear channel-discover pear.phing.info

Adding Channel "pear.phing.info" succeeded
Discovery of channel "pear.phing.info" succeeded

> pear install phing/phing
phing/phing can optionally use package
"pear/VersionControl_SVN" (version >= 0.3.0alpha1)
Starting to download phing-2.3.0beta1.tgz (397,990 bytes)
........................done: 397,990 bytes
install ok: channel://pear.phing.info/phing-2.3.0beta1

At this point, Phing is installed. Since you’re working with Subversion, and Phing optionally
supports Subversion, you should get the PEAR VersionControl_SVN package, too. You could try
to use pear install pear/VersionControl_SVN, but since it is an alpha package, you will probably
get an error like the following:

> pear install pear/VersionControl_SVN

Failed to download pear/VersionControl_SVN within preferred state "stable",
latest release is version 0.3.1, stability "alpha", use
"channel://pear.php.net/VersionControl_SVN-0.3.1" to install
Cannot initialize 'pear/VersionControl_SVN', invalid or missing package file
Package "pear/VersionControl_SVN" is not valid
install failed

So, instead, you must install it using the full-channel URI:

> pear install channel://pear.php.net/VersionControl_SVN-0.3.1

downloading VersionControl_SVN-0.3.1.tgz ...
Starting to download VersionControl_SVN-0.3.1.tgz (33,483 bytes)
.........done: 33,483 bytes
install ok: channel://pear.php.net/VersionControl_SVN-0.3.1

Now, with the PEAR packages installed, it’s time to write your first build file.

McArthur_819-9C08.fm Page 115 Friday, February 22, 2008 9:06 AM

Free download pdf