public static function createFromDirectory($packageName, $extensionDir)
{
$packageXmlPath = $extensionDir . DIRECTORY_SEPARATOR . 'package.xml';
// If the package.xml exists, we may get the configureoptions for configuring the Makefile
// and use the provided extension name to enable the extension.
//
// Currently only PECL extensions have package.xml, however It's the
// best strategy to install the extension.
if (file_exists($packageXmlPath)) {
// $this->logger->warning("===> Using xml extension meta");
if ($ext = self::createPeclExtension($packageName, $packageXmlPath)) {
return $ext;
}
}
// If the config.m4 or config0.m4 exists, it requires us to run `phpize` to
// initialize the `configure` script.
//
// It's basically a fallback for extensions that don't have package.xml.
// Generlly, The possible extensions using this strategy are usually
// PHP's core extensions, which are shipped in the distribution file.
// quote:
// the 0 there makes sure it gets into another stage of the buildprocess, the
// top IIRC, it was added @ 12th May 2001, 12:09am (10 months ago).
//
// http://grokbase.com/t/php/php-dev/023cpdc9k6/quick-summary-of-changes
//
// When config[0-9].m4 found, it might be an extension that can't be
// installed as a shared extension. We will need to raise a warning
// message for users.
$configM4Paths = self::configM4Exists($extensionDir);
foreach ($configM4Paths as $m4path) {
if (file_exists($m4path)) {
try {
$ext = self::createM4Extension($packageName, $m4path);
if ($ext) {
return $ext;
}
} catch (Exception $e) {
// Can't parse the content, ignore the error and continue the parsing...
}
}
}
}