| ユーザフォーラムで議論/質問 | マニュアル検索 | ハイライト | ハイライトオフ | ポータル | php spot |
Pyrus plugins: custom file rolesIntroductionIf 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="http://pear2.php.net/dtd/customrole-2.0"> <name>rolename</name> <class>MyPlugin_Rolename</class> [<validationmethod>validate</validationmethod>] [<autoloadpath>relative/path/to/MyPlugin</autoloadpath>] (<releasetype>php</releasetype>|<releasetype>extsrc</releasetype>| <releasetype>extbin</releasetype>|<releasetype>zendextsrc</releasetype>| <releasetype>zendextbin</releasetype>) <installable>(1|0)</installable> <locationconfig>config_var</locationconfig> <honorsbaseinstall>(1|0)</honorsbaseinstall> <unusualbaseinstall>(1|0)</unusualbaseinstall> <executable>(1|0)</executable> [<configvar> <name>config_name</name> <type>string</type> <default> <![CDATA[ <?php $default = 'hi'; ?> ]]> </default> <doc>Extensive, multi-line documentation</doc> [<validset>val1</validset><validset>val2</validset>...] <prompt>summary documentation</prompt> <group>Custom</group> <configtype>(system|user|channel-specific)</configtype> </configvar>]* </role> 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 timeSome 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:
<?php
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 rolesThe <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:
<installable>If set to 0, the file will not actually be installed onto the system. Most file roles should set this to 1. <locationconfig>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. <executable>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 variablesA 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. |
各種マニュアル:
PHPマニュアル |
PEARマニュアル |
Smarty(英語)マニュアル |
PHP-GTKマニュアル |
「Pyrus plugins: custom file roles」をGoogle検索
|