示例#1
1
 public function compile($pharFile, $name = 'foo-app', array $files = array(), array $directories = array(), $stub_file, $base_path, $name_pattern = '*.php', $strip = TRUE)
 {
     if (file_exists($pharFile)) {
         unlink($pharFile);
     }
     $phar = new \Phar($pharFile, 0, $name);
     // The signature is automatically set unless we decide to compress. In that
     // case we have to manually set it. Setting to the default just in case.
     $phar->setSignatureAlgorithm(\Phar::SHA1);
     $phar->startBuffering();
     // CLI Component files
     $iterator = Finder::create()->files()->name($name_pattern)->in($directories);
     // We need to set the adapter to use the PhpAdapter because we are working
     // with Phar files and the higher priority ones by default in symfony can
     // run into issues.
     //$iterator->removeAdapters();
     //$iterator->addAdapter(new PhpAdapter());
     $files = array_merge($files, iterator_to_array($iterator));
     foreach ($files as $file) {
         $path = str_replace($base_path . '/', '', $file);
         if ($strip) {
             $phar->addFromString($path, php_strip_whitespace($file));
         } else {
             $phar->addFromString($path, file_get_contents($file));
         }
     }
     $phar->setStub(file_get_contents($stub_file));
     $phar->stopBuffering();
     // Not all systems support compressed Phars. For now disabling.
     // $phar->compressFiles(\Phar::GZ);
     chmod($pharFile, 0755);
     unset($phar);
 }
示例#2
0
    public function testItExtractsIconFromPhar()
    {
        $key = uniqid();
        $iconContent = $key;
        $rootPackage = dirname(dirname(__FILE__));
        $iconRelativePath = 'Resources/notification/icon-' . $key . '.png';
        $testDir = sys_get_temp_dir() . '/test-jolinotif';
        $pharPath = $testDir . '/notification-extract-icon-' . $key . '.phar';
        $extractedIconPath = sys_get_temp_dir() . '/jolinotif/' . $iconRelativePath;
        if (!is_dir($testDir)) {
            mkdir($testDir);
        }
        $bootstrap = <<<'PHAR_BOOTSTRAP'
<?php

require __DIR__.'/vendor/autoload.php';

$iconPath = THE_ICON;
$notification = new \Joli\JoliNotif\Notification();
$notification->setBody('My notification');
$notification->setIcon(__DIR__.$iconPath);
PHAR_BOOTSTRAP;
        $phar = new \Phar($pharPath);
        $phar->buildFromDirectory($rootPackage, '#(src|tests/fixtures|vendor/composer)#');
        $phar->addFromString('bootstrap.php', str_replace('THE_ICON', '\'/' . $iconRelativePath . '\'', $bootstrap));
        $phar->addFromString($iconRelativePath, $iconContent);
        $phar->addFile('vendor/autoload.php');
        $phar->setStub($phar->createDefaultStub('bootstrap.php'));
        $this->assertTrue(is_file($pharPath));
        exec('php ' . $pharPath);
        $this->assertTrue(is_file($extractedIconPath));
        $this->assertSame($iconContent, file_get_contents($extractedIconPath));
    }
/**
 * Add a file in phar removing whitespaces from the file
 *
 * @param Phar   $phar
 * @param string $sFile
 * @param null   $baseDir
 */
function addFile($phar, $sFile, $baseDir = null)
{
    if (null !== $baseDir) {
        $phar->addFromString(substr($sFile, strlen($baseDir) + 1), php_strip_whitespace($sFile));
    } else {
        $phar->addFromString($sFile, php_strip_whitespace($sFile));
    }
}
示例#4
0
 /**
  * @param \Phar $phar
  * @param SplFileInfo $file
  */
 private function addFile(\Phar $phar, SplFileInfo $file)
 {
     $path = $file->getRelativePathname();
     $content = file_get_contents($file);
     $content = preg_replace('{^#!/usr/bin/env php\\s*}', '', $content);
     $phar->addFromString($path, $content);
 }
 public function compile()
 {
     if (file_exists('symfony.phar')) {
         unlink('symfony.phar');
     }
     $phar = new \Phar('symfony.phar', 0, 'Symfony');
     $phar->setSignatureAlgorithm(\Phar::SHA1);
     $phar->startBuffering();
     // Files
     foreach ($this->getFiles() as $file) {
         $path = str_replace(__DIR__ . '/', '', $file);
         if (false !== strpos($file, '.php')) {
             $content = Kernel::stripComments(file_get_contents($file));
         } else {
             $content = file_get_contents($file);
         }
         $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);
 }
示例#6
0
 public function run()
 {
     $this->printTaskInfo('Creating {filename}', ['filename' => $this->filename]);
     $this->phar->setSignatureAlgorithm(\Phar::SHA1);
     $this->phar->startBuffering();
     $this->printTaskInfo('Packing {file-count} files into phar', ['file-count' => count($this->files)]);
     $this->startProgressIndicator();
     foreach ($this->files as $path => $content) {
         $this->phar->addFromString($path, $content);
         $this->advanceProgressIndicator();
     }
     $this->phar->stopBuffering();
     $this->advanceProgressIndicator();
     if ($this->compress and in_array('GZ', \Phar::getSupportedCompression())) {
         if (count($this->files) > 1000) {
             $this->printTaskInfo('Too many files. Compression DISABLED');
         } else {
             $this->printTaskInfo('{filename} compressed', ['filename' => $this->filename]);
             $this->phar = $this->phar->compressFiles(\Phar::GZ);
         }
     }
     $this->advanceProgressIndicator();
     $this->stopProgressIndicator();
     $this->printTaskSuccess('{filename} produced', ['filename' => $this->filename]);
     return Result::success($this, '', ['time' => $this->getExecutionTime()]);
 }
示例#7
0
 public function run()
 {
     $this->printTaskInfo("Creating <info>{$this->filename}</info>");
     $this->phar->setSignatureAlgorithm(\Phar::SHA1);
     $this->phar->startBuffering();
     $this->printTaskInfo('Packing ' . count($this->files) . ' files into phar');
     $progress = new ProgressBar($this->getOutput());
     $progress->start(count($this->files));
     $this->startTimer();
     foreach ($this->files as $path => $content) {
         $this->phar->addFromString($path, $content);
         $progress->advance();
     }
     $this->phar->stopBuffering();
     $progress->finish();
     $this->getOutput()->writeln('');
     if ($this->compress and in_array('GZ', \Phar::getSupportedCompression())) {
         if (count($this->files) > 1000) {
             $this->printTaskInfo("Too many files. Compression DISABLED");
         } else {
             $this->printTaskInfo($this->filename . " compressed");
             $this->phar = $this->phar->compressFiles(\Phar::GZ);
         }
     }
     $this->stopTimer();
     $this->printTaskSuccess("<info>{$this->filename}</info> produced");
     return Result::success($this, '', ['time' => $this->getExecutionTime()]);
 }
示例#8
0
 private function addFile(\Phar $phar, \SplFileInfo $file)
 {
     $path = str_replace(dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR, '', $file->getRealPath());
     $content = file_get_contents($file);
     $content = $this->stripWhitespace($content);
     $phar->addFromString($path, $content);
 }
示例#9
0
 protected function addFile(\Phar $phar, \splFileInfo $file, $strip = true)
 {
     $path = str_replace(dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR, '', $file->getRealPath());
     $content = file_get_contents($file);
     if ($strip) {
         $content = self::stripWhitespace($content);
     }
     $phar->addFromString($path, $content);
 }
示例#10
0
 /**
  * Add a file into the Phar binary
  * @param \SplFileInfo $file The file to be added
  * @since 1.0.0
  */
 protected function addFile(\SplFileInfo $file)
 {
     $path = str_replace($this->root, '', $file->getRealPath());
     $content = file_get_contents($file);
     $content = preg_replace('{^#!/usr/bin/env php\\s*}', '', $content);
     if ($this->processor instanceof ProcessorInterface) {
         $content = $this->processor->process($content);
     }
     $this->phar->addFromString($path, $content);
 }
示例#11
0
 protected function addFile(\Phar $phar, \SplFileInfo $file, $strip = true)
 {
     $path = str_replace(dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR, '', $file->getRealPath());
     $content = file_get_contents($file);
     if ($strip) {
         $content = self::stripWhitespace($content);
     }
     $content = preg_replace("/const VERSION = '.*?';/", "const VERSION = '" . $this->version . "';", $content);
     $phar->addFromString($path, $content);
 }
 protected function addFile(File $file, $path, $stripBin = false)
 {
     $this->output->writeln(' <info>*</info> Add php file ' . $path);
     $content = $file->getContents();
     if ($stripBin) {
         $content = preg_replace('~^#!/usr/bin/env php\\s*~', '', $content);
         $content = str_replace('BundlerPackCommand', 'UpdateCommand', $content);
     }
     $this->phar->addFromString($path, $content);
 }
示例#13
0
 /**
  * Add a file to the psysh Phar.
  *
  * @param Phar $phar
  * @param SplFileInfo $file
  * @param bool $strip (default: true)
  */
 private function addFile($phar, $file, $strip = true)
 {
     $path = str_replace(dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR, '', $file->getRealPath());
     $content = file_get_contents($file);
     if ($strip) {
         $content = $this->stripWhitespace($content);
     } elseif ('LICENSE' === basename($file)) {
         $content = "\n" . $content . "\n";
     }
     $phar->addFromString($path, $content);
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('Building Phar archive');
     $file = 'build/zip.phar.php';
     if (file_exists($file)) {
         $output->writeln('Removing previous phar archive');
         unlink($file);
     }
     $output->writeln('Buffering contents ...');
     $phar = new \Phar($file, 0, 'zip.phar');
     $phar->setSignatureAlgorithm(\Phar::SHA1);
     $phar->startBuffering();
     $finder = new Finder();
     $finder->in(array('app', 'src', 'vendor'))->files(array('*.php', '*.js'));
     $count = $finder->count();
     $output->writeln(sprintf('Found %d entries', $count));
     $step = $count / 100;
     $index = 0;
     $indexStep = 0;
     /** @var ProgressHelper $progress */
     $progress = $this->getHelperSet()->get('progress');
     $progress->setFormat(' [%bar%] %percent%%');
     $progress->start($output, 100);
     /** @var SplFileInfo $file */
     $basePath = realpath(__DIR__ . '/../../../../../');
     foreach ($finder as $file) {
         $path = str_replace($basePath, '', $file->getRealPath());
         $path = ltrim($path, DIRECTORY_SEPARATOR);
         $path = str_replace(DIRECTORY_SEPARATOR, '/', $path);
         $phar->addFromString($path, $file->getContents());
         if ($index++ % $step == 0 && $indexStep < 100) {
             $progress->advance();
             $indexStep++;
         }
     }
     $phar->addFromString('index.php', file_get_contents($basePath . DIRECTORY_SEPARATOR . 'index.php'));
     $phar->setStub('<?php Phar::mapPhar("zip.phar"); define("PHAR_RUNNING", true); /*Phar::interceptFileFuncs();*/ require "phar://zip.phar/index.php"; __HALT_COMPILER();');
     $phar->stopBuffering();
     $progress->finish();
     $output->writeln('Build complete. Phar archive has been deployed to build/zip.phar.php');
 }
示例#15
0
    public function build()
    {
        $file = getTmpFile("phar");
        $phar = new \Phar($file);
        $phar->setStub("<?php __HALT_COMPILER(); ?>");
        $phar->setSignatureAlgorithm(\Phar::SHA1);
        $phar->startBuffering();
        $namespace = "_{$this->name}" . randomClass(8, "\\_");
        $class = randomClass(8);
        $main = "{$namespace}\\{$class}";
        $manifest = ["name" => $this->name, "version" => $this->version, "authors" => $this->authors, "api" => "1.9.0", "main" => $main, "commands" => []];
        foreach ($this->cmds as $cmd) {
            $manifest["commands"][$cmd->name] = ["description" => $cmd->desc, "usage" => $cmd->usage];
        }
        $phar->addFromString("plugin.yml", yaml_emit($manifest));
        $mainClass = <<<EOS
<?php
namespace {$namespace};
use pocketmine\\command as cmd;
use pocketmine\\event as evt;
class {$class} extends \\pocketmine\\plugin\\PluginBase implements evt\\Listener{
public function onCommand(cmd\\CommandSender \$sender, cmd\\Command\\ \$cmd, \$lbl, array \$args){
switch(\$cmd->getName()){
EOS;
        foreach ($this->cmds as $cmd) {
            $mainClass .= "case " . var_export($cmd->name, true) . ":" . PHP_EOL;
            $mainClass .= "return \$this->onCommand_{$cmd->name}(\$args, \$sender);" . PHP_EOL;
        }
        $mainClass .= "}" . PHP_EOL . "return false;" . PHP_EOL . "}" . PHP_EOL;
        foreach ($this->cmds as $cmd) {
            $mainClass .= $cmd->executor->toPhp();
        }
        $mainClass .= "}";
        $phar->addFromString("src/" . str_replace("\\", "/", $main) . ".php", $mainClass);
        //		$phar->compressFiles(\Phar::GZ);
        $phar->stopBuffering();
        $path = $phar->getPath();
        header("Content-Type: application/octet-stream");
        echo file_get_contents($path);
        //		unlink($path);
    }
示例#16
0
 public function compile($pharFile = 'gisele.phar')
 {
     if (file_exists($pharFile)) {
         unlink($pharFile);
     }
     $p = new Process('git rev-parse HEAD', __DIR__);
     if (0 !== $p->run()) {
         throw new \RuntimeException('Unable to get current version, you must compile the phar from the Gisele git repository');
     }
     $this->version = trim($p->getOutput());
     $phar = new \Phar($pharFile, 0, 'gisele.phar');
     $phar->setSignatureAlgorithm(\Phar::SHA1);
     $phar->startBuffering();
     $finder = Finder::create()->files()->ignoreVCS(true)->name('*.php')->notName('PharCompiler.php')->in(__DIR__ . '/../');
     // Add src
     foreach ($finder as $file) {
         $path = str_replace(dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR, '', $file->getRealPath());
         if (false !== strpos($path, 'Gisele.php')) {
             $content = str_replace('@version@', substr($this->version, 0, 8), file_get_contents($path));
             $phar->addFromString($path, $content);
         } else {
             $phar->addFile($path);
         }
     }
     $finder = Finder::create()->files()->ignoreVCS(true)->name('*.php')->exclude('Tests')->exclude('bin')->in(__DIR__ . '/../../vendor/fabpot/')->in(__DIR__ . '/../../vendor/guzzle/')->in(__DIR__ . '/../../vendor/symfony/')->in(__DIR__ . '/../../vendor/composer/');
     foreach ($finder as $file) {
         $path = str_replace(dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR, '', $file->getRealPath());
         $phar->addFile($path);
     }
     $path = str_replace(dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR, '', realpath(__DIR__ . '/../../vendor/autoload.php'));
     $phar->addFile($path);
     $content = file_get_contents(__DIR__ . '/../../bin/gisele');
     $content = preg_replace('{^#!/usr/bin/env php\\s*}', '', $content);
     $phar->addFromString('bin/gisele', $content);
     $phar->setStub($this->getStub());
     $phar->stopBuffering();
     unset($phar);
 }
示例#17
0
 protected function addFile(\Phar $phar, \SplFileInfo $file, $strip = true)
 {
     $path = str_replace(dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR, '', $file->getRealPath());
     $content = file_get_contents($file);
     if ($strip) {
         $content = self::stripWhitespace($content);
     } elseif ('LICENSE' === basename($file)) {
         $content = "\n" . $content . "\n";
     }
     if ($path === 'src/Monitor.php') {
         $content = str_replace('@package_version@', $this->version, $content);
     }
     $phar->addFromString($path, $content);
 }
示例#18
0
 /**
  * Saves binary in phar archive
  * @param \recompilr\Binary\PharBinary\AggregateCompiler $compiler
  */
 public function save(CompilerInterface $compiler)
 {
     $contents = '';
     if ($compiler instanceof AggregateCompiler) {
         $compilers = $compiler->getCompilers();
         foreach ($compilers as $compiler) {
             $contents .= parent::recompile($compiler);
         }
     } else {
         $contents = parent::recompile($compiler);
     }
     $phar = new \Phar($this->fileName);
     $phar->addFromString('bin.rcx', $contents);
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $pharFile = $input->getOption('phar');
     $this->unlink($pharFile);
     $phar = new \Phar($pharFile, 0, 'php-cg.phar');
     $phar->setSignatureAlgorithm(\Phar::SHA1);
     $phar->startBuffering();
     $finder = new Finder();
     $finder->files('*.php')->exclude(array('test', 'build'))->in(array('src', 'vendor'));
     foreach ($finder as $file) {
         /* @var \Symfony\Component\Finder\SplFileInfo $file */
         $path = str_replace(dirname(realpath(__DIR__ . '/../../../../../php-cg')) . DIRECTORY_SEPARATOR, '', $file->getRealPath());
         $path = str_replace('\\', '/', $path);
         $phar->addFromString($path, file_get_contents($file->getRealPath()));
     }
     $phpCg = file_get_contents(__DIR__ . '/../../../../../php-cg');
     $phpCg = preg_replace('/^.*?(<\\?php.*)/ms', '\\1', $phpCg);
     $phar->addFromString('php-cg', $phpCg);
     $phar->setStub($this->getStub());
     $phar->stopBuffering();
     unset($phar);
     chmod($pharFile, 0777);
 }
示例#20
0
 /**
  * @throws \RuntimeException
  */
 public function compile()
 {
     $this->checkWorkingDirectory();
     $this->checkVersion();
     if (file_exists($this->pharFile)) {
         unlink($this->pharFile);
     }
     $this->phar->setSignatureAlgorithm(Phar::SHA1);
     $this->phar->startBuffering();
     $finder = new Finder();
     $finder->files()->ignoreVCS(true)->name('*.php')->notName('Compiler.php')->exclude('Test')->in('vendor/composer')->in('vendor/assimtech/sysexits')->in('vendor/symfony/console')->in('vendor/symfony/polyfill-mbstring')->in('vendor/symfony/process')->in('vendor/symfony/yaml')->in('src');
     foreach ($finder as $file) {
         $this->phar->addFile($file);
     }
     $this->phar->addFile('vendor/autoload.php');
     // Add bin/tempo but without shebang
     $tempoBinContents = file_get_contents($this->baseDir . '/bin/tempo');
     $tempoBinPhar = preg_replace('{^#!/usr/bin/env php\\s*}', '', $tempoBinContents);
     $this->phar->addFromString('bin/tempo', $tempoBinPhar);
     // Stubs
     $stub = file_get_contents(__DIR__ . '/tempo.phar.stub');
     $this->phar->setStub($stub);
     $this->phar->stopBuffering();
 }
示例#21
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (ini_get('phar.readonly')) {
         $output->writeln('<info>PHP option "phar.readonly" must be set to 0.</info>');
         $output->writeln('<info>Try `php -d phar.readonly=0 ' . $GLOBALS['argv'][0] . ' compile:phar`</info>');
         return 1;
     }
     if (!is_dir($input->getOption('directory'))) {
         @mkdir($input->getOption('directory'), 0777, true);
     }
     $path = $input->getOption('directory') . DIRECTORY_SEPARATOR . $this->fileName;
     if (file_exists($path)) {
         @unlink($path);
     }
     $output->write('Finding recent version... ');
     $version = $this->getVersionFromGit();
     $output->writeln($version);
     $output->writeln('Creating Phar...');
     $phar = new \Phar($path, 0, $this->fileName);
     $phar->setSignatureAlgorithm(\Phar::SHA1);
     $phar->startBuffering();
     $finder = Finder::create()->in('.')->files()->name('*.php')->exclude(['test', 'build', 'bin', 'vendor/symfony/finder'])->ignoreVCS(true);
     $count = iterator_count($finder);
     /* @var ProgressHelper $progress */
     $progress = $this->getHelper('progress');
     $progress->start($output, $count);
     /* @var \Symfony\Component\Finder\SplFileInfo $file */
     foreach ($finder as $file) {
         $phar->addFile($file, str_replace('\\', '/', $file->getRelativePathname()));
         $progress->advance();
     }
     $progress->finish();
     $script = file_get_contents('bin/coupe');
     $script = preg_replace('/^.*?(<\\?php.*)/ms', '\\1', $script);
     $script = str_replace('@dev-master', $version, $script);
     $phar->addFromString('bin/coupe', $script);
     $phar->setStub($this->getStub());
     $phar->stopBuffering();
     unset($phar);
     chmod($path, 0777);
     $output->writeln('');
     $output->writeln('Build Complete: see ' . $path);
     return 0;
 }
示例#22
0
 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);
         $phar->addFromString($path, file_get_contents($file));
     }
     // 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);
 }
示例#23
0
文件: PackPhar.php 项目: sliver/Robo
 public function run()
 {
     $this->printTaskInfo("creating <info>{$this->filename}</info>");
     $this->phar->setSignatureAlgorithm(\Phar::SHA1);
     $this->phar->startBuffering();
     $this->printTaskInfo('packing ' . count($this->files) . ' files into phar');
     $progress = new ProgressHelper();
     $progress->start($this->getOutput(), count($this->files));
     foreach ($this->files as $path => $content) {
         $this->phar->addFromString($path, $content);
         $progress->advance();
     }
     $this->phar->stopBuffering();
     $progress->finish();
     if ($this->compress and in_array('GZ', \Phar::getSupportedCompression())) {
         $this->printTaskInfo($this->filename . " compressed");
         $this->phar = $this->phar->compressFiles(\Phar::GZ);
     }
     $this->printTaskInfo($this->filename . " produced");
     return Result::success($this);
 }
示例#24
0
 public function compile($pharFile = 'silex.phar')
 {
     if (file_exists($pharFile)) {
         unlink($pharFile);
     }
     $phar = new \Phar($pharFile, 0, 'Silex');
     $phar->setSignatureAlgorithm(\Phar::SHA1);
     $phar->startBuffering();
     $finder = new Finder();
     $finder->files()->name('*.php')->exclude('tests')->in(__DIR__ . '/..');
     foreach ($finder as $file) {
         $path = str_replace(realpath(__DIR__ . '/../..') . '/', '', realpath($file));
         $content = Kernel::stripComments(file_get_contents($file));
         $phar->addFromString($path, $content);
     }
     // Stubs
     $phar['_cli_stub.php'] = $this->getStub();
     $phar['_web_stub.php'] = $this->getStub();
     $phar->setDefaultStub('_cli_stub.php', '_web_stub.php');
     $phar->stopBuffering();
     // $phar->compressFiles(\Phar::GZ);
     unset($phar);
 }
<?php

$files = array("lib/widgets/Widgets.php", "lib/events/FormBeginEventArgs.php", "lib/events/FormEndEventArgs.php", "lib/Core.php", "lib/database/MySqlDatabase.php", "lib/utils/DateUtil.php", "js/global.js", "files/_emptyDirectory", "files/search/schema.xml", "vendor/Fusonic/Linq/Internal/WhereIterator.php", "vendor/Fusonic/Linq/Internal/SelectManyIterator.php", "vendor/Fusonic/Linq/Internal/SelectIterator.php", "vendor/Fusonic/Linq/Internal/DiffIterator.php", "vendor/Fusonic/Linq/Internal/GroupIterator.php", "vendor/Fusonic/Linq/Internal/DistinctIterator.php", "vendor/Fusonic/Linq/Internal/LinqHelper.php", "vendor/Fusonic/Linq/Internal/OrderIterator.php", "vendor/Fusonic/Linq/Internal/IntersectIterator.php", "vendor/Fusonic/Linq/GroupedLinq.php", "vendor/Fusonic/Linq.php", "vendor/Fusonic/UI/Widgets/Forms/FormBegin.php", "vendor/Fusonic/UI/Widgets/Forms/FormSectionBuilder.php", "vendor/Fusonic/UI/Widgets/Forms/AutoSelect.php", "vendor/Fusonic/UI/Widgets/Forms/ControlGroup.php", "vendor/Fusonic/UI/Widgets/Forms/FormEnd.php", "vendor/Fusonic/UI/Widgets/WidgetBase.php", "modules/calendar/ajax/calendarGetInvitedUsersContentAjaxHandler.php", "modules/calendar/js/calendarAppointmentForm.js", "modules/calendar/misc/calendarAppointment.php", "modules/calendar/pages/forms/calendarAppointmentForm.php", "modules/calendar/setup/config.xml", "modules/cmt/js/cmtMicroCommentsWidget.js", "modules/cmt/setup/config.xml", "modules/meta/misc/metaContentHelper.php", "modules/meta/setup/config.xml", "modules/brd/misc/brdPostStreamFormatter.php", "modules/brd/misc/brdPost.php", "modules/brd/setup/config/streamContents.xml", "modules/brd/setup/resources/lang/en.xml", "modules/brd/setup/resources/lang/de.xml", "modules/brd/setup/config.xml", "modules/auth/misc/authLoginService.php", "modules/auth/setup/config.xml", "modules/bwd/cache/bwdWordCacheCreator.php", "modules/bwd/bwd.php", "modules/bwd/setup/config.xml", "modules/nws/templates/pages/forms/nwsNewsForm.tpl", "modules/nws/templates/pages/nwsShowNewsPage.tpl", "modules/nws/pages/forms/nwsNewsForm.php", "modules/nws/pages/nwsShowNewsPage.php", "modules/nws/setup/config.xml", "modules/gmp/cache/gmpMarkersCacheCreator.php", "modules/gmp/select/gmpMapContentSelect.php", "modules/gmp/templates/gmpShowAppointmentPage.tpl", "modules/gmp/templates/gmpShowLinkPage.tpl", "modules/gmp/setup/config.xml", "modules/mul/cache/mulVideoPortalCacheCreator.php", "modules/mul/misc/mulPermissionHelper.php", "modules/mul/templates/widgets/mulFileEmbedWidget_Video_Flv.tpl", "modules/mul/setup/config/mulUploadVideoPortalMatches.xml", "modules/mul/setup/config.xml", "modules/cat/select/catCategorySelect.php", "modules/cat/misc/catCategory.php", "modules/cat/templates/pages/forms/catCategoryForm.tpl", "modules/cat/pages/forms/catEditCategoryForm.php", "modules/cat/pages/forms/catAddCategoryForm.php", "modules/cat/setup/config.xml", "modules/sty/events/styPageShowEventHandler.php", "modules/sty/misc/styBox.php", "modules/sty/templates/pages/forms/styLayoutForm.tpl", "modules/sty/templates/pages/forms/styBoxForm.tpl", "modules/sty/templates/pages/forms/styVariantForm.tpl", "modules/sty/setup/resources/lang/en.xml", "modules/sty/setup/resources/lang/de.xml", "modules/sty/setup/config.xml", "modules/reg/misc/regRegistrationHelper.php", "modules/reg/setup/config.xml", "modules/not/misc/notEmailNotificationProvider.php", "modules/not/setup/config.xml", "modules/styfusonic/setup/config.xml", "modules/sys/ajax/sysUserAutoSuggestSelectAjaxHandler.php", "modules/sys/js/sysUserAutoSuggestSelect.js", "modules/sys/select/sysPermissionSelect.php", "modules/sys/misc/sysHtaccessConfigWriter.php", "modules/sys/misc/sysUserRepository.php", "modules/sys/setup/resources/lang/en.xml", "modules/sys/setup/resources/lang/de.xml", "modules/sys/setup/config.xml", "modules/igr/boxes/igrGreatestEntriesBoxTab.php", "modules/igr/boxes/igrTopRatedEntriesBoxTab.php", "modules/igr/setup/config.xml", "modules/rat/ajax/ratRateAjaxHandler.php", "modules/rat/ajax/ratUnlikeAjaxHandler.php", "modules/rat/setup/config.xml", "modules/search/select/searchModuleSelect.php", "modules/search/select/searchOrderSelect.php", "modules/search/misc/searchResultFormatter.php", "modules/search/misc/searchProviderSolr.php", "modules/search/misc/searchProviderLucene.php", "modules/search/misc/searchResultItem.php", "modules/search/misc/searchProviderBase.php", "modules/search/misc/searchIProvider.php", "modules/search/templates/misc/searchResultFormatter.tpl", "modules/search/templates/pages/searchIndexPage.tpl", "modules/search/templates/pages/forms/searchSearchForm.tpl", "modules/search/pages/forms/searchSearchForm.php", "modules/search/css/searchResultFormatter.css", "modules/search/setup/config/sysSettings.xml", "modules/search/setup/resources/lang/en.xml", "modules/search/setup/resources/lang/de.xml", "modules/search/setup/config.xml", "style/Fusonic/40components.css", "style/_emptyDirectory", "index.php");
// Create Phar with the filenames above
$phar = new Phar(__DIR__ . "/bug65028.phar");
foreach ($files as $file) {
    $phar->addFromString($file, "");
}
// Copy phar
copy(__DIR__ . "/bug65028.phar", __DIR__ . "/bug65028-copy.phar");
// Open phar
try {
    $phar = new Phar(__DIR__ . "/bug65028-copy.phar");
    echo "No exception thrown.\n";
} catch (UnexpectedValueException $ex) {
    echo "Exception thrown: " . $ex->getMessage() . "\n";
}
示例#26
0
#!/usr/bin/env php
<?php 
const PHAR_FILE = __DIR__ . '/../blackhole-bot.phar';
const EXEC_FILE = __DIR__ . '/../blackhole-bot';
$phar = new Phar(PHAR_FILE, 0, 'blackhole-bot.phar');
/**
 * Add files to phar
 */
$append = new AppendIterator();
$append->append(new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__ . '/../src/', FilesystemIterator::SKIP_DOTS)));
$append->append(new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__ . '/../vendor/', FilesystemIterator::SKIP_DOTS)));
$append->append(new ArrayIterator(['src/Config/Services/services.yml' => realpath(__DIR__ . '/../src/Config/Services/services.yml')]));
$phar->addFromString('bin/blackhole', str_replace('#!/usr/bin/env php', '', file_get_contents(__DIR__ . '/../bin/blackhole')));
/**
 * Build the phar
 */
$phar->buildFromIterator($append, __DIR__ . '/..');
// start buffering. Mandatory to modify stub.
$phar->startBuffering();
// Get the default stub. You can create your own if you have specific needs
$defaultStub = $phar->createDefaultStub('bin/blackhole');
// Adding files
$phar->buildFromDirectory(__DIR__, '/\\.php$/');
// Create a custom stub to add the shebang
$stub = "#!/usr/bin/env php \n" . $defaultStub;
// Add the stub
$phar->setStub($stub);
$phar->stopBuffering();
chmod(PHAR_FILE, 0755);
rename(PHAR_FILE, EXEC_FILE);
示例#27
0
<?php

$mindbody = new Phar("mboapi.phar");
$mindbody->startBuffering();
$files = new AppendIterator();
$files->append(new DirectoryIterator("services"));
$files->append(new DirectoryIterator("structures"));
$mindbody->buildFromIterator($files, dirname(__FILE__));
$mindbody->addFile("LICENSE");
$mindbody->addFile("README.markdown");
$mindbody->addFromString("loadServices.php", "<?php\n\tinclude_once(\"services/Appointment_Service.php\");\n\tinclude_once(\"services/Class_Service.php\");\n\tinclude_once(\"services/Client_Service.php\");\n\tinclude_once(\"services/Sale_Service.php\");\n\tinclude_once(\"services/Site_Service.php\");\n\tinclude_once(\"services/Staff_Service.php\");\n\tinclude_once(\"services/Data_Service.php\");\n\tinclude_once(\"services/Finder_Service.php\");\n?>");
$mindbody->setStub($mindbody->createDefaultStub("loadServices.php"));
$mindbody->stopBuffering();
foreach (new RecursiveIteratorIterator($mindbody) as $file) {
    echo $file->getFileName() . "\n";
}
示例#28
0
 /**
  * Adds a file to phar archive.
  *
  * @param SplFileInfo $file file info
  * @param Phar        $phar phar packager
  */
 protected function addFileToPhar(\SplFileInfo $file, \Phar $phar)
 {
     $path = str_replace($this->libPath . '/', '', $file->getRealPath());
     $phar->addFromString($path, file_get_contents($file));
 }
示例#29
0
<?php

$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
$pname = 'phar://' . $fname;
$phar = new Phar($fname);
$phar->addFromString('a', 'hi');
echo file_get_contents($pname . '/a') . "\n";
$phar->addFile($pname . '/a', 'b');
echo file_get_contents($pname . '/b') . "\n";
try {
    $phar->addFile($pname . '/a');
} catch (Exception $e) {
    echo $e->getMessage() . "\n";
}
try {
    $phar->addFile($pname . '/a', 'a');
} catch (Exception $e) {
    echo $e->getMessage() . "\n";
}
try {
    $phar->addFile(dirname(__FILE__) . '/does/not/exist');
} catch (Exception $e) {
    echo $e->getMessage() . "\n";
}
try {
    $phar->addFile($pname . '/a', '.phar/stub.php');
} catch (Exception $e) {
    echo $e->getMessage() . "\n";
}
try {
    $phar->addFromString('.phar/stub.php', 'hi');
示例#30
0
 /**
  * Adds the given file to the PHAR archive,
  *
  * Before adding files to the archive they are bein converted to
  * relative paths.
  *
  * @param string $file
  * @param \Phar  $phar
  *
  * @return void
  */
 protected function addFileToPharArchive($file, \Phar $phar)
 {
     $path = str_replace(__DIR__ . '/', '', $file);
     $file_contents = file_get_contents($file);
     $file_contents = str_replace('#!/usr/bin/env php', '', $file_contents);
     $phar->addFromString($path, $file_contents);
 }