当前位置: 首页>>代码示例>>PHP>>正文


PHP Phar类代码示例

本文整理汇总了PHP中Phar的典型用法代码示例。如果您正苦于以下问题:PHP Phar类的具体用法?PHP Phar怎么用?PHP Phar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Phar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testOpenSSLSignature

 public function testOpenSSLSignature()
 {
     if (!extension_loaded('OpenSSL')) {
         $this->markTestSkipped("Need OpenSSL extension");
     }
     // Generate a private key on the fly.
     $passphrase = uniqid();
     $passfile = PHING_TEST_BASE . '/etc/tasks/ext/pharpackage/pass.txt';
     file_put_contents($passfile, $passphrase);
     $pkey = openssl_pkey_new();
     openssl_pkey_export_to_file($pkey, PHING_TEST_BASE . '/etc/tasks/ext/pharpackage/priv.key', $passphrase);
     $this->executeTarget(__FUNCTION__);
     // Make sure we are dealing with an OpenSSL signature.
     // (Phar silently falls back to an SHA1 signature
     // whenever it fails to add an OpenSSL signature)
     $dest = PHING_TEST_BASE . '/etc/tasks/ext/pharpackage/pharpackage.phar';
     $this->assertFileExists($dest);
     $phar = new Phar($dest);
     $signature = $phar->getSignature();
     $this->assertEquals('OpenSSL', $signature['hash_type']);
     unlink(PHING_TEST_BASE . '/etc/tasks/ext/pharpackage/priv.key');
     unlink(PHING_TEST_BASE . '/etc/tasks/ext/pharpackage/pharpackage.phar.pubkey');
     unlink(PHING_TEST_BASE . '/etc/tasks/ext/pharpackage/pass.txt');
     unlink($dest);
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:25,代码来源:PharPackageTaskTest.php

示例2: addFile

 /**
  * @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);
 }
开发者ID:webcreate,项目名称:conveyor,代码行数:11,代码来源:PharTask.php

示例3: compile

 public function compile($pharFile = 'already-extract.phar')
 {
     if (file_exists($pharFile)) {
         unlink($pharFile);
     }
     $phar = new \Phar($pharFile, 0, 'already-extract.phar');
     $phar->setSignatureAlgorithm(\Phar::SHA1);
     $phar->startBuffering();
     $finder = new Finder();
     $finder->files()->ignoreVCS(true)->name('*.php')->notName('Compiler.php')->in(__DIR__ . '/..');
     foreach ($finder as $file) {
         $this->addFile($phar, $file);
     }
     $finder = new Finder();
     $finder->files()->ignoreVCS(true)->name('*.php')->exclude('Tests')->in(__DIR__ . '/../../vendor/symfony/');
     foreach ($finder as $file) {
         $this->addFile($phar, $file);
     }
     $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../vendor/autoload.php'));
     $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../vendor/composer/autoload_namespaces.php'));
     $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../vendor/composer/autoload_psr4.php'));
     $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../vendor/composer/autoload_classmap.php'));
     $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../vendor/composer/autoload_real.php'));
     $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../vendor/composer/ClassLoader.php'));
     $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../vendor/composer/include_paths.php'));
     $this->addAlreadyExtractBin($phar);
     $phar->setStub($this->getStub());
     $phar->stopBuffering();
     unset($phar);
 }
开发者ID:mhor,项目名称:already-extract,代码行数:30,代码来源:Compiler.php

示例4: compile

 /**
  * Compiles the Hydra source code into one single Phar file.
  *
  * @param string $pharFile Name of the output Phar file
  */
 public function compile($pharFile = 'hydra.phar')
 {
     if (file_exists($pharFile)) {
         unlink($pharFile);
     }
     $phar = new \Phar($pharFile, 0, 'hydra.phar');
     $phar->startBuffering();
     $finder = new Finder();
     $finder->files()->ignoreVCS(true)->name('*.php')->name('*.twig')->notName('PharCompiler.php')->exclude('Tests')->in('src')->in('views')->in('../../twig/twig/lib')->in('../../monolog/monolog/src')->in('../../symfony/http-kernel/Symfony/Component/HttpKernel/Exception')->in('../../symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType')->in('../../symfony/http-foundation/Symfony/Component/HttpFoundation/File/Exception');
     foreach ($finder as $file) {
         $this->addFile($phar, $file);
     }
     $this->addFile($phar, new \SplFileInfo('../../symfony/http-foundation/Symfony/Component/HttpFoundation/HeaderBag.php'));
     $this->addFile($phar, new \SplFileInfo('../../symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php'));
     $this->addFile($phar, new \SplFileInfo('../../symfony/http-foundation/Symfony/Component/HttpFoundation/ResponseHeaderBag.php'));
     $this->addFile($phar, new \SplFileInfo('../../symfony/http-kernel/Symfony/Component/HttpKernel/Debug/ErrorHandler.php'));
     $this->addFile($phar, new \SplFileInfo('../../symfony/http-kernel/Symfony/Component/HttpKernel/Debug/ExceptionHandler.php'));
     $this->addFile($phar, new \SplFileInfo('../../autoload.php'));
     $this->addFile($phar, new \SplFileInfo('../../composer/ClassLoader.php'));
     $this->addFile($phar, new \SplFileInfo('../../composer/autoload_namespaces.php'));
     $this->addFile($phar, new \SplFileInfo('../../composer/autoload_classmap.php'));
     $phar->setStub($this->getStub());
     $phar->stopBuffering();
     //        $phar->compressFiles(\Phar::GZ);
 }
开发者ID:z7,项目名称:hydra,代码行数:30,代码来源:PharCompiler.php

示例5: _build

 protected static function _build($conf)
 {
     $pathToPhar = $conf['path_to_phar'];
     $pharName = $conf['phar_name'];
     $srcPath = $conf['src_path'];
     $initModule = $conf['init_module'];
     $setup = $conf['setup'];
     $file = $pathToPhar . '/' . $pharName;
     if ($conf['delete_old_phar_onbuild'] && \file_exists($file)) {
         \unlink($file);
     }
     $falias = $pharName;
     $mapPhar = $pharName;
     $phar = new \Phar($file, 0, $falias);
     $phar->startBuffering();
     $dir = $phar->buildFromDirectory($srcPath);
     $stub = '<?php ' . "\\Phar::mapPhar('{$falias}'); " . 'include ' . "'phar://{$falias}/{$initModule}'; " . "{$setup}" . '__HALT_COMPILER();';
     $phar->setStub($stub);
     //
     //
     if (isset($conf['compress_pkg']) && $conf['compress_pkg'] == 'GZ') {
         $phar->compressFiles(\Phar::GZ);
     }
     //
     //
     $phar->stopBuffering();
 }
开发者ID:swwwfactory,项目名称:entry8,代码行数:27,代码来源:utils.php

示例6: addFile

 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);
 }
开发者ID:bcncommerce,项目名称:magebuild,代码行数:7,代码来源:Compiler.php

示例7: compile

 /**
  * Compiles composer into a single phar file
  *
  * @throws \RuntimeException
  */
 public function compile()
 {
     $pharFile = 'refactor.phar';
     if (file_exists($pharFile)) {
         unlink($pharFile);
     }
     $process = new Process('git log --pretty="%H" -n1 HEAD', $this->directory);
     if ($process->run() != 0) {
         throw new \RuntimeException('Can\'t run git log. You must ensure to run compile from git repository clone and that git binary is available.');
     }
     $this->version = trim($process->getOutput());
     $process = new Process('git describe --tags HEAD');
     if ($process->run() == 0) {
         $this->version = trim($process->getOutput());
     }
     $phar = new \Phar($pharFile, 0, 'refactor.phar');
     $phar->setSignatureAlgorithm(\Phar::SHA1);
     $phar->startBuffering();
     $finder = new Finder();
     $finder->files()->ignoreVCS(true)->name('*.php')->notName('Compiler.php')->in($this->directory . '/src/main');
     foreach ($finder as $file) {
         $this->addFile($phar, $file);
     }
     $finder = new Finder();
     $finder->files()->ignoreVCS(true)->name('*.php')->exclude('test')->exclude('features')->in($this->directory . '/vendor/');
     foreach ($finder as $file) {
         $this->addFile($phar, $file);
     }
     $this->addRefactorBin($phar);
     // Stubs
     $phar->setStub($this->getStub());
     $phar->stopBuffering();
     unset($phar);
 }
开发者ID:roozbehmatloobi,项目名称:php-refactoring-browser,代码行数:39,代码来源:Compiler.php

示例8: doExecute

    /**
     * Method to run the application routines.  Most likely you will want to instantiate a controller
     * and execute it, or perform some sort of task directly.
     *
     * @return  void
     *
     * @since   2.0
     */
    protected function doExecute()
    {
        if ($this->io->getOption('h') || $this->io->getOption('help')) {
            $this->help();
            return;
        }
        $dir = $this->io->getOption('d', '../../vaseman.phar');
        $file = __DIR__ . '/' . $dir;
        if (is_file($file)) {
            unlink($file);
        }
        $this->out('Start generating...');
        $phar = new Phar($file);
        $phar->setStub(<<<PHP
#!/usr/bin/env php
<?php

Phar::mapPhar('vaseman.phar');

require 'phar://vaseman.phar/bin/vaseman'; __HALT_COMPILER();
PHP
);
        $phar->buildFromDirectory(__DIR__ . '/..');
        $phar->stopBuffering();
        $this->out('Phar generated: ' . $file)->out();
    }
开发者ID:bgao-ca,项目名称:vaseman,代码行数:34,代码来源:build.php

示例9: compile

 public function compile($pharFile = self::PHAR_FILE, $root_dir = null)
 {
     if (is_null($root_dir)) {
         $this->root_dir = dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR;
     } else {
         $this->root_dir = rtrim($root_dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
     }
     if (file_exists($pharFile)) {
         unlink($pharFile);
     }
     $phar = new \Phar($pharFile, 0, self::PHAR_NAME);
     $phar->setSignatureAlgorithm(\Phar::SHA1);
     $phar->startBuffering();
     $finder = $this->getDefaultFinder();
     $finder->name('*.php');
     foreach ($finder as $file) {
         $this->__addFile($phar, $file);
     }
     $finder = $this->getDefaultFinder();
     $finder->name('*.json')->name('*.ini')->name('*.man')->name('*.md')->name('*.tpl')->name('LICENSE');
     foreach ($finder as $file) {
         $this->__addFile($phar, $file, false);
     }
     // global binary
     $this->__addBin($phar);
     // add the __stub
     $phar->setStub($this->__getStub());
     $phar->stopBuffering();
     unset($phar);
     return $this->_logs;
 }
开发者ID:atelierspierrot,项目名称:markdown-extended,代码行数:31,代码来源:Compiler.php

示例10: compile

 /**
  * Compiles satis into a single phar file
  *
  * @param  string $pharFile The full path to the file to create
  *
  * @throws \RuntimeException
  */
 public function compile($pharFile = 'satis.phar')
 {
     if (file_exists($pharFile)) {
         unlink($pharFile);
     }
     $phar = new \Phar($pharFile, 0, 'satis.phar');
     $phar->setSignatureAlgorithm(\Phar::SHA1);
     $phar->startBuffering();
     $finders = array();
     $finder = new Finder();
     $finder->files()->ignoreVCS(true)->name('*.php')->notName('Compiler.php')->in(__DIR__ . '/../../');
     $finders[] = $finder;
     $finder = new Finder();
     $finder->files()->name('*')->in(__DIR__ . '/../../../views/');
     $finders[] = $finder;
     $finder = new Finder();
     $finder->files()->ignoreVCS(true)->name('*.php')->name('composer-schema.json')->exclude(array('phpunit', 'mikey179', 'phpdocumentor', 'sebastian', 'phpspec', 'doctrine', 'test', 'tests', 'Tests'))->in(__DIR__ . '/../../../vendor/');
     $finders[] = $finder;
     foreach ($finders as $finder) {
         foreach ($finder as $file) {
             $this->addFile($phar, $file);
         }
     }
     $this->addSatisBin($phar);
     // Stubs
     $phar->setStub($this->getStub());
     $phar->stopBuffering();
     $phar->compressFiles(\Phar::GZ);
     $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../../LICENSE'), false);
     $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../../res/satis-schema.json'), false);
     unset($phar);
 }
开发者ID:ausger,项目名称:satis,代码行数:39,代码来源:Compiler.php

示例11: compile

 /**
  * Compiles composer into a single phar file
  *
  * @throws \RuntimeException
  * @param string $pharFile The full path to the file to create
  */
 public function compile($pharFile = 'composer.phar')
 {
     if (file_exists($pharFile)) {
         unlink($pharFile);
     }
     $process = new Process('git log --pretty="%h" -n1 HEAD');
     if ($process->run() != 0) {
         throw new \RuntimeException('The git binary cannot be found.');
     }
     $this->version = trim($process->getOutput());
     $phar = new \Phar($pharFile, 0, 'composer.phar');
     $phar->setSignatureAlgorithm(\Phar::SHA1);
     $phar->startBuffering();
     $finder = new Finder();
     $finder->files()->ignoreVCS(true)->name('*.php')->notName('Compiler.php')->in(__DIR__ . '/..');
     foreach ($finder as $file) {
         $this->addFile($phar, $file);
     }
     $finder = new Finder();
     $finder->files()->ignoreVCS(true)->name('*.php')->in(__DIR__ . '/../../vendor/symfony/');
     foreach ($finder as $file) {
         $this->addFile($phar, $file);
     }
     $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../vendor/.composer/ClassLoader.php'));
     $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../vendor/.composer/autoload.php'));
     $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../vendor/.composer/autoload_namespaces.php'));
     $this->addComposerBin($phar);
     // Stubs
     $phar->setStub($this->getStub());
     $phar->stopBuffering();
     // disabled for interoperability with systems without gzip ext
     // $phar->compressFiles(\Phar::GZ);
     $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../LICENSE'), false);
     unset($phar);
 }
开发者ID:natxet,项目名称:composer,代码行数:41,代码来源:Compiler.php

示例12: compile

 /**
  * Compiles compify into a single phar file
  *
  * @throws \RuntimeException
  * @param  string            $pharFile The full path to the file to create
  */
 public function compile($pharFile = 'compify.phar')
 {
     if (file_exists($pharFile)) {
         unlink($pharFile);
     }
     $phar = new \Phar($pharFile, 0, 'compify.phar');
     $phar->setSignatureAlgorithm(\Phar::SHA1);
     $phar->startBuffering();
     $finders = array();
     $finder = new Finder();
     $finder->files()->ignoreVCS(true)->name('*.php')->notName('Compiler.php')->in(__DIR__ . '/../../');
     $finders[] = $finder;
     $finder = new Finder();
     $finder->files()->ignoreVCS(true)->name('*.php')->name('composer-schema.json')->in(__DIR__ . '/../../../vendor/');
     $finders[] = $finder;
     foreach ($finders as $finder) {
         foreach ($finder as $file) {
             $this->addFile($phar, $file);
         }
     }
     $this->addSatisBin($phar);
     // Stubs
     $phar->setStub($this->getStub());
     $phar->stopBuffering();
     $phar->compressFiles(\Phar::GZ);
     $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../../LICENSE'), false);
     unset($phar);
 }
开发者ID:stevleibelt,项目名称:compify,代码行数:34,代码来源:Compiler.php

示例13: compile

 /**
  * Compiles composer into a single phar file
  *
  * @throws \RuntimeException
  * @param  string            $pharFile The full path to the file to create
  */
 public function compile($pharName)
 {
     echo "Creating phar archive" . PHP_EOL;
     $this->pharName = $pharName;
     $pharFile = __DIR__ . DIRECTORY_SEPARATOR . $pharName;
     if (file_exists($pharFile)) {
         unlink($pharFile);
     }
     $phar = new \Phar($pharFile, 0, $pharName);
     $phar->setSignatureAlgorithm(\Phar::SHA1);
     $phar->startBuffering();
     foreach ($this->directories as $folder) {
         $finder = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($folder, FilesystemIterator::SKIP_DOTS));
         foreach ($finder as $file) {
             if ($this->isWhitelisted($file) && !$this->isBlacklisted($file)) {
                 $this->addFile($phar, $file);
             }
         }
     }
     $this->addFile($phar, $this->entryPoint);
     // Stubs
     $phar->setStub($this->getStub());
     $phar->stopBuffering();
     unset($phar);
 }
开发者ID:AdrianAulbach,项目名称:db-sync,代码行数:31,代码来源:createphar.php

示例14: compile

 /**
  * Compiles the Slic source code into one single Phar file.
  *
  * @param string $pharFile Name of the output Phar file
  */
 public function compile($pharFile = 'slic.phar')
 {
     if (file_exists($pharFile)) {
         unlink($pharFile);
     }
     $process = new Process('git log --pretty="%h %ci" -n1 HEAD');
     if ($process->run() > 0) {
         throw new \RuntimeException('The git binary cannot be found.');
     }
     $this->version = trim($process->getOutput());
     $phar = new \Phar($pharFile, 0, 'slic.phar');
     $phar->setSignatureAlgorithm(\Phar::SHA1);
     $phar->startBuffering();
     $root = __DIR__ . '/../../..';
     $finder = new Finder();
     $finder->files()->ignoreVCS(true)->name('*.php')->notName('Compiler.php')->exclude('Tests')->in($root . '/src')->in($root . '/vendor/symfony');
     foreach ($finder as $file) {
         $this->addFile($phar, $file);
     }
     $this->addFile($phar, new \SplFileInfo($root . '/LICENSE'), false);
     $this->addFile($phar, new \SplFileInfo($root . '/vendor/autoload.php'));
     $this->addFile($phar, new \SplFileInfo($root . '/vendor/composer/ClassLoader.php'));
     $this->addFile($phar, new \SplFileInfo($root . '/vendor/composer/autoload_namespaces.php'));
     $this->addFile($phar, new \SplFileInfo($root . '/vendor/composer/autoload_classmap.php'));
     $this->addFile($phar, new \SplFileInfo($root . '/vendor/composer/autoload_real.php'));
     // Stubs
     $phar->setStub($this->getStub());
     $phar->stopBuffering();
     // $phar->compressFiles(\Phar::GZ);
     unset($phar);
 }
开发者ID:siphoc,项目名称:slic,代码行数:36,代码来源:Compiler.php

示例15: buildModulePhar

function buildModulePhar($name, $format = Phar::PHAR, $compression = Phar::NONE, $executable = true, $fake = false)
{
    echo "Building {$name}...\t";
    $glob = glob($name.'.*');
    if (count($glob) > 0) {
        foreach ($glob as $file) {
            if (!is_dir($file)) {
                unlink($file);
            }   
        }
    }
    $filename = $name . '.phar';
    $phar = new Phar($filename);
    if ($fake) {
        $phar['Module.php'] = '<?php //no class here';
    } else {
        $phar['Module.php'] = "<?php \n\nnamespace $name;\n\nclass Module\n{}";
    }
    if (false === $executable) {
        $phar->convertToData($format, $compression);
    } else {
        $phar->setDefaultStub('Module.php', 'Module.php');
        if ($format !== Phar::PHAR || $compression !== Phar::NONE) {
            $phar->convertToExecutable($format, $compression);
        }
    }
    if ($format !== Phar::PHAR || $compression !== Phar::NONE) {
        unlink($filename);
    }
    echo "Done!\n";
}
开发者ID:noose,项目名称:zf2,代码行数:31,代码来源:_buildPhars.php


注:本文中的Phar类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。