Setting Up Your Component's Package.xml File
In my Beyond Frameworks talk, I explained how a component-based architecture can help answer some of the important (i.e. expensive!) questions you might face when creating long-lived apps that rely on a PHP framework. In this series of blog posts, I'm going to look at how to go about creating and working with components.
In the last article, I edited the build.properties file to set the component's name and version number. I need to finish setting up the component's metadata by editing package.xml.
Every PEAR-compatible component needs to ship with a manifest file called package.xml. You can see the the unedited version on GitHub that we're about to change.
package.xml contains the following useful information:
- The component's name, channel, version number, and description.
- A list of the component's authors.
- The component's license.
- A list of the component's contents.
- A list of the component's dependencies, including PHP version, PHP extensions, and other components.
(package.xml can hold other information too, but I've yet to see them being put to practical use, so we'll leave them for today and come back to them if needed later on).
In our component skeleton, we need to add some of this data to package.xml, and the rest will be added automatically by the tools when we build a PEAR-compatible package, to save us the trouble of doing it by hand.
Setting Up The Component's Name And Channel
All PEAR-compatible packages have a fully-qualified name of the form /. In this skeleton, our tools will automatically inject project.name from the build.properties file into package.xml's tag when we build the PEAR-compatible package. We just need to edit the tag in package.xml to point to our server.
As I'm going to publish these packages via our public PEAR channel, I've set to be a€opear.gradwell.coma€¯. Don't worry if you don't have your own PEAR channel yet; they're very easy to create, and I'll look at exactly how to set one up and publish it later in this series.
Setting Up The Component's Version Number, And Description
All PEAR-compatible packages have a version number. We've already set this in build.properties; our tools will automatically inject this into package.xml. (We could have put this directly into package.xml, but the version number is duplicated in a couple of places, and it seems much easier to let the tools deal with that so that we don't forget to update all the version numbers when we make a new release).
For the description, edit the <:summary and tags. The descriptions get used in the human-friendly html page that each PEAR channel has, so they're worth the trouble of filling in.
Setting Up The Component's Author
There's a few tags inside package.xml that tell anyone who is interested who the current author of the component is. This information gets used in the human-friendly html page that each PEAR channel has. I've set these tags as follows:Stuart Herbert
Truncated by Planet PHP, read more at the original (another 4179 bytes)