PEAR logo

PEAR_PackageFileManager : The Definitive Guide



Chapter 11. Using custom file roles

Table of Contents

Add a new extension role mapping
Improve warning message requiring custom file role handler

This lesson :

Add a new extension role mapping

Default role mapping array separates extension into seven categories.

Table 11.1. extension role mapping reference

Role Extension
php php
data all other extension
doc html
test none
script none
src h, c, m4, w32
ext dll

Once a package that reference, manage, the new role is properly installed in your system, you can use it, and add it to the default role mapping array.

We suppose to have previously installed a package that manage the new role web. Here we will assume that all log files (*.log) will be copied into directory declared by <locationconfig> tag of xml web file role (see PEAR/Installer/Role/Web.xml).

  1. $p2->addRole('log', 'web');

However, if a user does not have the package installed that provides the custom role web, then the error message on installation will simply say File ... has invalid role "web" should be one of data, doc, php, script, test which is not very helpful.

If you don't want to give the same behavior to all file with same extension, but only to one or a set of them, then use option directive exceptions.

  1. $p2->setOptions(array(
  2.     // ...
  3.     'exceptions' => array('index.php' => 'web'),
  4.     );
PEAR_PackageFileManager : The Definitive Guide v 1.6.0 : November 17, 2006