-
Notifications
You must be signed in to change notification settings - Fork 0
Creating a PEAR package
Since version 0.7.3 there is a new API for creating PEAR packages.
This new API relies on the Pearfarm-API which is installed automatically if you haven’t installed it already.
To create your PEAR package just create a new task:
<?php
namespace pantr\file;
use pantr\ext\Pearfarm\PackageSpec;
/**
* Build a pear package
*/
task('build:package', function() {
$spec = PackageSpec::in('src')
->setName('<project name>')
->setChannel('pear.yourserver.com')
->setSummary('whatever')
->setDescription('whatever')
->setNotes('n/a')
->setVersion('1.0.0')
->setStability('stable')
->setLicense(PackageSpec::LICENSE_MIT)
->addMaintainer('lead', '<your name>', '<username>', '<email>')
->setDependsOnPHPVersion('5.3.0')
->addFiles(fileset()
->ignore_version_control()
->relative()
->in('src'))
->createPackage();
});
The PackageSpec class extends Pearfarms Pearfarm_PackageSpec class and adds a few methods. You have, however, the full Pearfarm API at your disposal.
After you have created your package you can deploy it using Pirum on your own server or on Pearfarm. The APIs for Pirum already exist (pantr\ext\Pirum) and we will improve Pearfarm deployment support soon.
To deploy your package using Pirum, you can use something around these lines:
/**
- Publish the pear package on pear channel
*
- @dependsOn build:package
*/
task(‘deploy’, function($args) {
Pirum::onChannel(property(‘pear.dir’))
→addLatestVersion(‘dist’);
});
Unless you have some magic working, you’ll still need to upload the modified pear repository. Of course you can use pantr to perform that task using either FTPDeploy (cross-platform) or LFTP (unix only; requires you to have installed the LFTP tool).
Since this is a rather generic task which might be useful in most of your projects, you may want to provide and include a file from ~/.pantr
which defines the necessary task (or a function which defines it).