-Command help:
-
- $ ./vendor/bin/pharext --help
-
-Yields:
-
- Usage:
-
- $ ./vendor/bin/pharext [-h|-v|-q|-g|-p] -s <arg> -n <arg> -r <arg> [-d <arg>]
-
- -h|--help Display this help
- -v|--verbose More output
- -q|--quiet Less output
- -s|--source <arg> Extension source directory (REQUIRED)
- -g|--git Use `git ls-files` instead of the standard ignore filter
- -p|--pecl Use PECL package.xml instead of the standard ignore filter
- -d|--dest <arg> Destination directory [.]
- -n|--name <arg> Extension name (REQUIRED)
- -r|--release <arg> Extension release version (REQUIRED)
+### Packager and installer hooks
+
+#### Packager hook
+If neither --pecl nor --git are explicitely given, pharext looks for a
+`pharext_install.php` in --source. This script will be exectuted by the
+Packager. It must return a callable with the following signature:
+
+ function(Packager $pkg, $path) : function(Packager $pkg, $path);
+
+So, the callback should return another callable.
+The primary callback is meant to set things like --name and --release,
+so you don't have to on the command line; build automation FTW.
+The secondary callback is meant to create the file iterator of the
+source dir, but if you're in a git clone, you might easily just return a
+new pharext\GitSourceDir and be done.
+
+##### Example for pecl_http
+
+pharext_package.php
+
+ <?php
+
+ namespace pharext;
+
+ return function(Packager $packager, $path) {
+ $args = $packager->getArgs();
+ $args->name = "pecl_http";
+ $args->release = current(preg_filter("/^.*PHP_PECL_HTTP_VERSION\s+\"(.*)\".*$/s", "\$1", file("../http.git/php_http.h")));
+ return function (Packager $packager, $path) {
+ return new GitSourceDir($packager, $path);
+ };
+ };
+
+#### Installer hook
+The packager will look for a `pharext_install.php` file within the root of
+the source dir. This script will be executed by the Installer; it must
+return a callable with the following signature:
+
+ function(Installer $installer) : function(Installer $installer);
+
+So, again, the callback should return another callable.
+The primary callback is meant to add your own command line arguments to
+the CliArgs parser, and the secnodary callback is meant to proccess
+those args.
+
+##### Example for pecl_http
+
+pharext_install.php
+
+ <?php
+
+ namespace pharext;
+
+ return function(Installer $installer) {
+ $installer->getArgs()->compile([
+ [null, "with-http-zlib-dir", "Where to find zlib",
+ CliArgs::OPTARG],
+ [null, "with-http-libcurl-dir", "Where to find libcurl",
+ CliArgs::OPTARG],
+ [null, "with-http-libevent-dir", "Where to find libev{,ent{,2}}",
+ CliArgs::OPTARG],
+ [null, "with-http-libidn-dir", "Where to find libidn",
+ CliArgs::OPTARG],
+ ]);
+
+ return function(Installer $installer) {
+ $opts = [
+ "with-http-zlib-dir",
+ "with-http-libcurl-dir",
+ "with-http-libevent-dir",
+ "with-http-libidn-dir",
+ ];
+ $args = $installer->getArgs();
+ foreach ($opts as $opt) {
+ if (isset($args[$opt])) {
+ $args->configure = "--$opt=".$args[$opt];
+ }
+ }
+ };
+ };
+
+#### PECL source dirs
+For --pecl source dirs a pharext_install.php script is automatically
+generated from the package.xml which adds defined configure options
+and automatically generates a file list.