For many small library packages, very little customization is needed. Just install and go. package.xml 1.0 is very good at this task. As packages grow in size and complexity, it is often necessary to make slight changes to the contents of files, and occasionally to external components such as databases.
package.xml 1.0 provides a single undocumented system of customizing file contents through the <replace> tag, like so:
<file name="blah.php" role="php"> <replace from="@token@" to="version" type="package-info"/> <replace from="@anothertoken@" to="php_dir" type="pear-config"/> </file>
This example above would scan the blah.php file at installation, and then use str_replace() to replace all occurences of the string @token@ with the package's version number. Then, it would replace all occurences of the string @anothertoken@ with the value of the user's php_dir configuration variable.
Although powerful, the replace tag is the only customization tag available in package.xml version 1.0. When developing package.xml version 2.0, the replace tag and innovative work of other projects such as Phing became the inspiration for an expanded kind customization called a "task".
Tasks are defined by xml children of a <file> tag. Tasks are implemented by extending the PEAR_Task_Common task.
Tasks are defined in package.xml through the tasks namespace, which is currently http://pear.php.net/dtd/tasks-1.0. The current tasks namespace is defined by http://pear.php.net/dtd/tasks-1.0.xsd. Custom tasks bundled with PEAR include:
The xml for each of these tasks is documented here.
|Defining a customized role for use in a package.xml||上に戻る||Creating customized tasks in PHP|