PHPマニュアル/PEARマニュアル | ユーザフォーラムで議論/質問 | マニュアル検索 | ハイライト | ハイライトオフ | ポータル | php spot

Pyrus plugins: custom file roles | JavaScript入門&応用&リファレンスなら「JavaScriptist」


Pyrus plugins: custom file roles


If you are not familiar with how file roles install, read the introduction to file roles first. This segment of the documentation assumes you are familiar with concepts such as baseinstalldir and with what a file role means in terms of installation location.

Custom file roles can implement a single role, and are defined by an xml file that is noted in package.xml with the customrole file role. The XML format is defined and validated by pyrus with the customrole-2.0.xsd XSchema file.

Here is a human-readable custom file role xml file definition. Optional elements are enclosed in [brackets], and if there is a choice of values, they are delimited with a vertical bar | and enclosed in (parentheses).

<?xml version="1.0" encoding="UTF-8"?>
<role version="2.0" xmlns="">
    <?php $default = 'hi'; ?>
  <doc>Extensive, multi-line documentation</doc>
  <prompt>summary documentation</prompt>

Telling Pyrus how to load your role: <class> and <autoloadpath>

This is the same method used for all plugins, and is documented here.

Validating your custom role at packaging time

Some roles benefit from the ability to validate the files they represent at packaging time. For instance, a customcommand file is checked to ensure it conforms to its XML schema, so that a custom command with invalid XML cannot be distributed by mistake.

By convention, a validation method should be named validate, although the xml supports any name. The method name should be placed in the <validationmethod tag, and the method itself should have the same method signature as this example from Pyrus's customrole validation:

function validate(\pear2\Pyrus\IPackage $package, array $file)
$parser = new \pear2\Pyrus\XMLParser;
$schemapath = \pear2\Pyrus\Main::getDataPath();
        if (!
file_exists(\pear2\Pyrus\Main::getDataPath() . '/customrole-2.0.xsd')) {
$schemapath realpath(__DIR__ '/../../../../data');
$taskschema $schemapath '/customrole-2.0.xsd';
        try {
$taskinfo $parser->parse($package->getFilePath($file['attribs']['name']), $taskschema);
        } catch (\
Exception $e) {
            throw new \
pear2\Pyrus\Installer\Role\Exception('Invalid custom role definition file,' .
' file does not conform to the schema'$e);

A custom file role package-time validator should throw a PEAR2_Pyrus_Installer_Role_Exception exception object with an error message describing the reason for validation failure, or simply return on success.

Release Types and file roles

The <releasetype> element is used to tell Pyrus which releases can contain a file with this role. For instance, the src role only has meaning in a PHP extension source release, and is only allowed in extsrc and zendextsrc release types.

There are 5 release types that Pyrus recognizes:

  • php - this is for PEAR-style packages distributing PHP code

  • extsrc - this is for PHP extension source packages

  • extbin - this is for PHP extension binary packages

  • zendextsrc - this is for PHP Zend extension source packages

  • zendextbin - this is for PHP Zend extension binary packages


If set to 0, the file will not actually be installed onto the system. Most file roles should set this to 1.


This element is used to tell Pyrus which configuration variable should be used to determine where to install the file. This can be a custom configuration variable.

<honorsbaseinstall> and <unusualbaseinstall>

The <honorsbaseinstall> element tells Pyrus to honor the baseinstalldir attribute (documentation on baseinstalldir is here) for roles like php.

The <unusualbaseinstall> element tells Pyrus to honor the baseinstalldir attribute for roles like data that also prepend channel/package name to the installation location.


If <executable> is set to 1, Pyrus will make the installed file an executable file on unix systems (the equivalent of

chmod +x filename


Defining custom configuration variables

A custom file role can optionally define a single or multiple custom configuration variables. There are 3 kinds of configuration variables that Pyrus supports, system, user and channel-specific. Documentation on configuration is available here. Read that before continuing in order to understand how different configuration variables work.

Pyrus supports one type of configuration variable: string. The values can be restricted to a specific set of values with the <validset> element.


フォーラムで「Pyrus plugins: custom file roles」について話す
各種マニュアル: PHPマニュアル | PEARマニュアル | Smarty(英語)マニュアル | PHP-GTKマニュアル | Pyrus plugins: custom file roles」をGoogle検索
copyright © 1997-2024 PHP ドキュメント作成グループ(ライセンス). provided by php spot. マニュアル: