Commit 0ea2603f authored by Ivan Enderlin's avatar Ivan Enderlin

Include vendors inside the PHAR.

Since Solarium has dependencies, this is more interesting to include
vendors (aka dependencies) inside the PHAR file.

Thus we include the `library/` directory with the `vendor/` directory.
parent 976c5b19
......@@ -49,27 +49,36 @@ $strip = (isset($options['s']) && $options['s'] == '1');
$start = microtime(true);
// Create a new Solarium phar file
// Create a new Solarium PHAR file.
@unlink('solarium.phar');
$phar = new Phar('solarium.phar', 0, 'solarium.phar');
$phar->setStub(file_get_contents("stub.php"));
$phar->setStub(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'stub.php'));
$phar->setSignatureAlgorithm(Phar::SHA1);
// Add files to the phar
$basePath = realpath(__DIR__."/../library/Solarium");
if ($strip) {
$directoryIterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($basePath),
// Add files to the PHAR.
$basePath = dirname(__DIR__);
$directoryIterator = new AppendIterator();
$directoryIterator->append(
new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($basePath . DIRECTORY_SEPARATOR . 'library'),
RecursiveIteratorIterator::SELF_FIRST
)
);
$directoryIterator->append(
new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($basePath . DIRECTORY_SEPARATOR . 'vendor'),
RecursiveIteratorIterator::SELF_FIRST
);
)
);
if ($strip) {
foreach ($directoryIterator as $file) {
if (preg_match('/\\.php$/i', $file)) {
if (0 !== preg_match('/\\.php$/i', $file)) {
$phar->addFromString(substr($file, strlen($basePath) + 1), php_strip_whitespace($file));
}
}
} else {
$phar->buildFromDirectory($basePath, '/\.php$/');
$phar->buildFromIterator($directoryIterator, $basePath);
}
// Create compressed versions
......@@ -79,4 +88,4 @@ if ($compress) {
}
$time = round(microtime(true)-$start, 5);
echo "\nDONE ($time seconds)\n\n";
echo "\nDONE ($time seconds)\nsolarium.php has been created.\n\n";
......@@ -34,7 +34,7 @@
*/
Phar::mapPhar("solarium.phar");
require_once 'phar://solarium.phar/Autoloader.php';
require_once 'phar://solarium.phar/library/Solarium/Autoloader.php';
Solarium\Autoloader::register();
if ('cli' === php_sapi_name() && basename(__FILE__) === basename($_SERVER['argv'][0]) && isset($_SERVER['argv'][1])) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment