Commit 5dc4d9c5 authored by Igor Wiedler's avatar Igor Wiedler

Support including a phar from another phar

The default stubs mess up when you try to run a phar which includes
another phar. In my case I was running pip.phar on the CLI, which
included app.php, which in turn included silex.phar.

It broke the __DIR__ calls. This was able to fix it.

Needs testing in lots of different setups, because the default stubs are
no longer used.
parent 36abb738
...@@ -36,7 +36,7 @@ class Compiler ...@@ -36,7 +36,7 @@ class Compiler
} }
$this->version = trim($process->getOutput()); $this->version = trim($process->getOutput());
$phar = new \Phar($pharFile, 0, 'Silex'); $phar = new \Phar($pharFile, 0, 'silex.phar');
$phar->setSignatureAlgorithm(\Phar::SHA1); $phar->setSignatureAlgorithm(\Phar::SHA1);
$phar->startBuffering(); $phar->startBuffering();
...@@ -66,9 +66,7 @@ class Compiler ...@@ -66,9 +66,7 @@ class Compiler
$this->addFile($phar, new \SplFileInfo(__DIR__.'/../../autoload.php')); $this->addFile($phar, new \SplFileInfo(__DIR__.'/../../autoload.php'));
// Stubs // Stubs
$phar['_cli_stub.php'] = $this->getStub(); $phar->setStub($this->getStub());
$phar['_web_stub.php'] = $this->getStub();
$phar->setDefaultStub('_cli_stub.php', '_web_stub.php');
$phar->stopBuffering(); $phar->stopBuffering();
...@@ -103,7 +101,9 @@ class Compiler ...@@ -103,7 +101,9 @@ class Compiler
* with this source code in the file LICENSE. * with this source code in the file LICENSE.
*/ */
require_once __DIR__.'/autoload.php'; Phar::mapPhar('silex.phar');
require_once 'phar://silex.phar/autoload.php';
if ('cli' === php_sapi_name()) { if ('cli' === php_sapi_name()) {
$command = isset($argv[1]) ? $argv[1] : null; $command = isset($argv[1]) ? $argv[1] : null;
......
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