Packager-hook
If neither --pecl
nor --git
are explicitely given, pharext
looks for a
pharext_package.php
in --source
.
This script will be exectuted by the Packager. It must return an
instance of pharext\SourceDir
, which provides every information the packager
needs to build the PHAR.
Here’s the interface declaration of pharext\SourceDir
:
<?php
namespace pharext;
/**
* Source directory interface, which should yield file names to package on traversal
*/
interface SourceDir extends \Traversable
{
/**
* Retrieve the base directory
* @return string
*/
public function getBaseDir();
/**
* Retrieve gathered package info
* @return array|Traversable
*/
public function getPackageInfo();
/**
* Retrieve the full text license
* @return string
*/
public function getLicense();
/**
* Provide installer command line args
* @return array|Traversable
*/
public function getArgs();
/**
* Process installer command line args
* @param \pharext\Cli\Args $args
*/
public function setArgs(Cli\Args $args);
}
Example for pecl_http
<?php
namespace pharext;
class PeclHttp extends SourceDir\Git
{
private $args = [
[null, "with-http-zlib-dir", "Where to find zlib",
Cli\Args::OPTARG],
[null, "with-http-libcurl-dir", "Where to find libcurl",
Cli\Args::OPTARG],
[null, "with-http-libevent-dir", "Where to find libevent",
Cli\Args::OPTARG],
[null, "with-http-libidn-dir", "Where to find libidn",
Cli\Args::OPTARG],
];
public function getPackageInfo() {
return [
"name" => "pecl_http",
"release" => current(preg_filter("/^.*PHP_PECL_HTTP_VERSION\s+\"(.*)\".*$/s", "\$1", file($this->path."/php_http.h"))),
"zend" => false,
];
}
public function getLicense() {
return file_get_contents($this->path . "/LICENSE");
}
public function getArgs() {
return $this->args;
}
public function setArgs(Cli\Args $args) {
foreach ($this->args as $arg) {
$name = $arg[1];
if (isset($args[$name])) {
$args->configure = "--{$name}={$args[$name]}";
}
}
}
}
return new PeclHttp(__DIR__);