Class: PEAR_PackageFileManager
Source Location: Program_Root/PackageFileManager.php
Class PEAR_PackageFileManager
Class Overview
PEAR :: PackageGenerate updates the <filelist></filelist> section of a PEAR package.xml file to reflect the current files in preparation for a release.
The PEAR_PackageGenerate class uses a plugin system to generate the list of files in a package. This allows both standard recursive directory parsing (plugin type file) and more intelligent options such as the CVS browser PEAR_PackageFileManager_Cvs, which grabs all files in a local CVS checkout to create the list, ignoring any other local files. Other options include specifying roles for file extensions (all .php files are role="php", for example), roles for directories (all directories named "tests" are given role="tests" by default), and exceptions. Exceptions are specific pathnames with * and ? wildcards that match a default role, but should have another. For example, perhaps a debug.tpl template would normally be data, but should be included in the docs role. Along these lines, to exclude files entirely, use the ignore option. Required options for a release include version, baseinstalldir, state, and packagedirectory (the full path to the local location of the package to create a package.xml file for) Example usage: 1 <?php 2 require_once('PEAR/PackageFileManager.php'); 3 $packagexml = new PEAR_PackageFileManager; 4 $e = $packagexml->setOptions( 5 array('baseinstalldir' => 'PhpDocumentor', 6 'version' => '1.2.1', 7 'packagedirectory' => 'C:/Web Pages/chiara/phpdoc2/', 8 'state' => 'stable', 9 'filelistgenerator' => 'cvs', // generate from cvs, use file for directory 10 'notes' => 'We\'ve implemented many new and exciting features', 11 'ignore' => array('TODO', 'tests/'), // ignore TODO, all files in tests/ 12 'installexceptions' => array('phpdoc' => '/*'), // baseinstalldir ="/" for phpdoc 13 'dir_roles' => array('tutorials' => 'doc'), 14 'exceptions' => array('README' => 'doc', // README would be data, now is doc 15 'PHPLICENSE.txt' => 'doc'))); // same for the license 16 if (PEAR::isError($e)) { 17 echo $e->getMessage(); 18 die(); 19 } 20 $packagexml->addRole('pkg', 'doc'); // add a new role mapping 21 $e = $packagexml->writePackageFile(); 22 if (PEAR::isError($e)) { 23 echo $e->getMessage(); 24 die(); 25 } 26 ?> 27 28 In addition, a package.xml file can now be generated from 29 scratch, with the usage of new options package, summary, description, and 30 the use of the method
Located in Program_Root/PackageFileManager.php [line 165]
|
Methods
|
Method Summary
void |
addDependency() |
Add a dependency on another package, or an extension/php |
void |
addMaintainer() |
Add a maintainer to the list of maintainers. |
void |
addRole() |
Add an extension/role mapping to the role mapping option |
void |
debugPackageFile() |
ALWAYS use this to test output before overwriting your package.xml!! |
void |
raiseError() |
Utility function to shorten error generation code |
void |
writePackageFile() |
Writes the package.xml file out with the newly created <release></release> tag |
Methods
PEAR_PackageFileManager PEAR_PackageFileManager(
)
|
|
void addConfigureOption(
string
$name, string
$prompt, [string
$default = null]
)
|
|
Add an install-time configuration option for building of source
This option is only useful to PECL projects that are built upon installation
Parameters:
string |
$name: |
name of the option |
string |
$prompt: |
prompt to display to the user |
string |
$default: |
default value |
void addDependency(
string
$name, [string
$version = false], [string
$operator = 'ge'], [string
$type = 'pkg']
)
|
|
Add a dependency on another package, or an extension/php
This will overwrite an existing dependency if it is found. In other words, if a dependency on PHP 4.1.0 exists, and addDependency('php', '4.3.0', 'ge', 'php') is called, the existing dependency on PHP 4.1.0 will be overwritten with the new one on PHP 4.3.0
Parameters:
string |
$name: |
Dependency element name |
string |
$version: |
Dependency version |
string |
$operator: |
A specific operator for the version, this can be one of: 'has', 'not', 'lt', 'le', 'eq', 'ne', 'ge', or 'gt' |
string |
$type: |
Dependency type. This can be one of: 'pkg', 'ext', 'php', 'prog', 'os', 'sapi', or 'zend' |
void addMaintainer(
string
$handle, lead|developer|contributor|helper
$role, string
$name, string
$email
)
|
|
Add a maintainer to the list of maintainers.
Every maintainer must have a valid account at pear.php.net. The first parameter is the account name (for instance, cellog is the handle for Greg Beaver at pear.php.net). Every maintainer has one of four possible roles: - lead: the primary maintainer
- developer: an important developer on the project
- contributor: self-explanatory
- helper: ditto
Finally, specify the name and email of the maintainer
Parameters:
string |
$handle: |
username on pear.php.net of maintainer |
lead|developer|contributor|helper |
$role: |
role of maintainer |
string |
$name: |
full name of maintainer |
string |
$email: |
email address of maintainer |
void addRole(
string
$extension, string
$role
)
|
|
Add an extension/role mapping to the role mapping option
Parameters:
string |
$extension: |
file extension |
string |
$role: |
role |
ALWAYS use this to test output before overwriting your package.xml!!
API Tags:
void raiseError(
mixed
$code, [mixed
$i1 = ''], [mixed
$i2 = '']
)
|
|
Utility function to shorten error generation code
API Tags:
void setOptions(
[array
$options = array()]
)
|
|
Parameters:
void writePackageFile(
[boolean
$debuginterface = null]
)
|
|
Writes the package.xml file out with the newly created <release></release> tag
Parameters:
boolean |
$debuginterface: |
null if no debugging, true if web interface, false if command-line |
Information Tags:
|
|