JavaScript Editor Javascript validator     Web page editor 

Chapter 20. The package definition file package.xml

Table of Contents
Introduction to the package definition file package.xml

Introduction to the package definition file package.xml

package.xml version 1.0 is deprecated

package.xml 1.0 is deprecated. You should really be using package.xml version 2.0. Documentation can be found at package.xml 2.0 documentation.

As of 2007-04, More than 99.8% of all PEAR installations in the wild are capable of using package.xml 2.0 files, so you should not worry about backwards compatibility.

The package definition file package.xml is, as the name already implies, a well-formed XML file that contains all information about a PEAR package.

This chapter will describe the allowed elements of the package definition file and it will discuss how to create such a file for your package.

The PEAR_PackageFileManager package simplifies the creation of package.xml. You can install PEAR_PackageFileManager via the usual command

$ pear install PEAR_PackageFileManager

Allowed elements

The toplevel element in package.xml is the element <package version="1.0">. The allowed sub elements are:


In order to validate package.xml files one can use the xmllint tool that comes with libxml2.

xmllint --dtdvalid --noout package.xml

Creating a package definition file

This package.xml can serve as a template for you as it already contains all necessary elements. In most cases you only need to change the character data between the tags in order to use the example in your package.

In this example you get to know a very handy feature: When you have a directory in your package that only contains files of the same type, you can add to role attribute even to the <dir> tag instead of adding it to every single <file> tag.

With the knowledge you've acquired from this chapter you should now be able to produce a package definition file for your own package. If you still have questions concerning the topic, don't hesitate to ask on the mailinglist.

Defining Dependencies

The PEAR Package Manager supports checking for different system capabilities. You define those dependencies with the <dep> tag:

JavaScript Editor Javascript validator     Web page editor