Phing addition: pearPackageFileSet

SemanticScuttle will be distributed as .phar file with the next version. The command line interface uses PEAR's awesome Console_CommandLine package, which needs to be packaged up in the Phar file to make it work out of the box.

I let Phing handle all of the deployment of new versions, and generating the Phar file is handled by Phing, too.

In general, adding files to a .phar is easy, even a bunch of PEAR installed files: Put their absolute locations in a <fileset> tag and you're set.

Unfortunately, this solution has several problems:

  1. The location of PEAR files may differ from machine to machine.
  2. The list of files may get really long - Console_CommandLine has 28 .php files. When I start to use HTML_QuickForm2 and need to bundle that, there are 67 more files to list. Manually.
  3. Package updates may add and remove files, so the list gets out of date easily.

I chose to go the correct way and solve all of the problems by writing a Fileset that takes care of everything. All I have to do is specify the package I want to package up:

<pearPackageFileSet package="Console_CommandLine" id="ccl" />
<pharpackage destfile="myapp.phar">
  <fileset refid="ccl"/>
</pharpackage>

This bit of Phing build file XML packages up all Console_CommandLine php files into myapp.phar.

I've opened a feature request on the Phing website to get it included in the official distribution and started a discussion to make it easier to integrate custom types in Phing in the future (see the ticket).

The README is available on GitHub, the code also on Gitorious. The task is in the official phing distribution since version 2.4.8.

Side note: The rSTTask I wrote about three months ago is part of Phing since 2.4.7.

Written by Christian Weiske.

Comments? Please send an e-mail.