public function compile($pharFile = 'goutte.phar') { if (file_exists($pharFile)) { unlink($pharFile); } $phar = new \Phar($pharFile, 0, 'Goutte'); $phar->setSignatureAlgorithm(\Phar::SHA1); $phar->startBuffering(); // CLI Component files foreach ($this->getFiles() as $file) { $path = str_replace(__DIR__ . '/', '', $file); $content = Kernel::stripComments(file_get_contents($file)); $content = preg_replace("#require_once 'Zend/.*?';#", '', $content); $phar->addFromString($path, $content); } // Stubs $phar['_cli_stub.php'] = $this->getCliStub(); $phar['_web_stub.php'] = $this->getWebStub(); $phar->setDefaultStub('_cli_stub.php', '_web_stub.php'); $phar->stopBuffering(); // $phar->compressFiles(\Phar::GZ); unset($phar); }
protected function addPhpFile(\Phar $phar, $name, $content) { $phar[$name] = Kernel::stripComments($content); }