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


PHP Phar::stopBuffering方法代码示例

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


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

示例1: makePlugin

 /**
  * Makes a .phar packaged PocketMine plugin from a source directory.
  *
  * @param $sourcePath
  * @param $pharOutputLocation
  * @param $options
  * @return bool
  * @throws \Exception
  */
 public static function makePlugin($sourcePath, $pharOutputLocation, $options)
 {
     /* Removes Leading '/' */
     $sourcePath = rtrim(str_replace("\\", "/", realpath($sourcePath)), "/") . "/";
     $description = self::getPluginDescription($sourcePath . "/plugin.yml");
     if ($options & self::MAKEPLUGIN_REAL_OUTPUT_PATH) {
         $pharPath = $pharOutputLocation;
     } else {
         $pharPath = $pharOutputLocation . DIRECTORY_SEPARATOR . $description->getName() . "_v" . $description->getVersion() . ".phar";
     }
     if (file_exists($pharPath)) {
         throw new \Exception("Phar path already exists");
     }
     $phar = new \Phar($pharPath);
     $phar->setMetadata(["name" => $description->getName(), "version" => $description->getVersion(), "main" => $description->getMain(), "api" => $description->getCompatibleApis(), "depend" => $description->getDepend(), "description" => $description->getDescription(), "authors" => $description->getAuthors(), "website" => $description->getWebsite(), "creationDate" => time()]);
     $phar->setStub('<?php echo "PocketMine-MP plugin ' . $description->getName() . ' v' . $description->getVersion() . '\\nThis file has been generated using DevTools v' . self::getVersion() . ' at ' . date("r") . '\\n----------------\\n";if(extension_loaded("phar")){$phar = new \\Phar(__FILE__);foreach($phar->getMetadata() as $key => $value){echo ucfirst($key).": ".(is_array($value) ? implode(", ", $value):$value)."\\n";}} __HALT_COMPILER();');
     $phar->setSignatureAlgorithm(\Phar::SHA1);
     $phar->startBuffering();
     foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($sourcePath)) as $file) {
         $path = ltrim(str_replace(["\\", $sourcePath], ["/", ""], $file), "/");
         if ($path[0] === "." or strpos($path, "/.") !== false) {
             continue;
         }
         $phar->addFile($file, $path);
     }
     if ($options * self::MAKEPLUGIN_COMPRESS) {
         $phar->compressFiles(\Phar::GZ);
     }
     $phar->stopBuffering();
     return true;
 }
开发者ID:sekjun9878,项目名称:makeplugin,代码行数:40,代码来源:MakePlugin.php

示例2: compile

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

示例3: run

 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()]);
 }
开发者ID:greg-1-anderson,项目名称:Robo,代码行数:26,代码来源:PackPhar.php

示例4: compile

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

示例5: close

 /**
  * Finish saving the package
  */
 function close()
 {
     if ($this->phar->isFileFormat(Phar::ZIP) && $this->compression !== Phar::NONE) {
         $this->phar->compressFiles($this->compression);
     }
     $this->phar->stopBuffering();
     $newphar = $this->phar;
     $ext = str_replace(array('.tar', '.zip', '.tgz', '.phar'), array('', '', '', ''), basename($this->path)) . '.';
     $ext = substr($ext, strpos($ext, '.'));
     if (count($this->others)) {
         foreach ($this->others as $pathinfo) {
             // remove the old file
             $newpath = str_replace(array('.tar', '.zip', '.tgz', '.phar'), array('', '', '', ''), $this->path);
             $newpath .= '.' . $pathinfo[0];
             if (file_exists($newpath)) {
                 unlink($newpath);
             }
             $extension = $ext . $pathinfo[0];
             $fileformat = $pathinfo[1];
             $compression = $pathinfo[2];
             if ($fileformat != Phar::PHAR) {
                 $newphar = $newphar->convertToData($fileformat, $compression, $extension);
             } else {
                 $newphar = $newphar->convertToExecutable($fileformat, $compression, $extension);
             }
         }
     }
 }
开发者ID:peopleplan,项目名称:Pyrus,代码行数:31,代码来源:Phar.php

示例6: run

 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()]);
 }
开发者ID:roland-d,项目名称:Robo,代码行数:28,代码来源:PackPhar.php

示例7: 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

示例8: execute

 /**
  * Execute the task
  *
  * @throws Exception
  * @return void
  */
 public function execute()
 {
     $target = $this->getOption('target');
     $sourceDirectory = $this->getOption('sourceDirectory');
     $stubFile = $this->getOption('stubFile');
     if (!extension_loaded('phar')) {
         throw new \Exception('Phar extension not loaded');
     }
     if (!is_dir($sourceDirectory)) {
         throw new \Exception('Source directory not found: ' . $sourceDirectory);
     }
     // check to see if we can create phar files
     $readOnly = ini_get('phar.readonly');
     if ($readOnly != 1) {
         $phar = new \Phar($target, 0, basename($target));
         $phar->startBuffering();
         $phar->buildFromDirectory($sourceDirectory);
         $stub = $phar->createDefaultStub();
         $phar->setStub($stub);
         $phar->stopBuffering();
         //$phar->compress(Phar::GZ);
     } else {
         throw new \Exception('Cannot create phar! (read-only enabled)');
     }
 }
开发者ID:robertbasic,项目名称:usher,代码行数:31,代码来源:Phar.php

示例9: build_phar

function build_phar()
{
    $phar = new Phar('build/bugsnag.phar');
    $phar->buildFromDirectory(dirname(__FILE__) . '/src', '/\\.php$/');
    $phar->compressFiles(Phar::GZ);
    $phar->stopBuffering();
    $phar->setStub($phar->createDefaultStub('Bugsnag/Autoload.php'));
}
开发者ID:ayurmedia,项目名称:faveo-helpdesk,代码行数:8,代码来源:pharbuilder.php

示例10: create

 static function create($phar_file, $php_dir, $default_stub)
 {
     $phar = new \Phar($phar_file);
     $phar->buildFromDirectory($php_dir, '/\\.php$/');
     $phar->compressFiles(\Phar::GZ);
     $phar->stopBuffering();
     $phar->setStub($phar->createDefaultStub($default_stub));
 }
开发者ID:jasonshaw,项目名称:framework-1,代码行数:8,代码来源:Phar.php

示例11: execute

 public function execute(CommandSender $sender, $commandLabel, array $args)
 {
     if (!$this->testPermission($sender)) {
         return false;
     }
     if (count($args) === 0) {
         $sender->sendMessage(TextFormat::RED . "Usage: " . $this->usageMessage);
         return true;
     }
     $pluginName = trim(implode(" ", $args));
     if ($pluginName === "" or !($plugin = Server::getInstance()->getPluginManager()->getPlugin($pluginName)) instanceof Plugin) {
         $sender->sendMessage(TextFormat::RED . "プラグインが存在しません");
         return true;
     }
     $description = $plugin->getDescription();
     if (!$plugin->getPluginLoader() instanceof FolderPluginLoader) {
         $sender->sendMessage(TextFormat::RED . "プラグイン " . $description->getName() . "はフォルダではありません");
         return true;
     }
     $pharPath = Server::getInstance()->getPluginPath() . DIRECTORY_SEPARATOR . "PocketMine-MO" . DIRECTORY_SEPARATOR . $description->getName() . "_v" . $description->getVersion() . ".phar";
     if (file_exists($pharPath)) {
         $sender->sendMessage("pharファイルが既に存在しているため、上書きします");
         @unlink($pharPath);
     }
     $phar = new \Phar($pharPath);
     $phar->setMetadata(["name" => $description->getName(), "version" => $description->getVersion(), "main" => $description->getMain(), "api" => $description->getCompatibleApis(), "geniapi" => $description->getCompatibleGeniApis(), "depend" => $description->getDepend(), "description" => $description->getDescription(), "authors" => $description->getAuthors(), "website" => $description->getWebsite(), "creator" => "PocketMine-MO MakePluginCommand", "creationDate" => time()]);
     if ($description->getName() === "DevTools") {
         $phar->setStub('<?php require("phar://". __FILE__ ."/src/DevTools/ConsoleScript.php"); __HALT_COMPILER();');
     } else {
         $phar->setStub('<?php echo "PocketMine-MP/ plugin ' . $description->getName() . ' v' . $description->getVersion() . '\\nThis file has been generated using PocketMine-MO by Meshida at ' . date("r") . '\\n----------------\\n";if(extension_loaded("phar")){$phar = new \\Phar(__FILE__);foreach($phar->getMetadata() as $key => $value){echo ucfirst($key).": ".(is_array($value) ? implode(", ", $value):$value)."\\n";}} __HALT_COMPILER();');
     }
     $phar->setSignatureAlgorithm(\Phar::SHA1);
     $reflection = new \ReflectionClass("pocketmine\\plugin\\PluginBase");
     $file = $reflection->getProperty("file");
     $file->setAccessible(true);
     $filePath = rtrim(str_replace("\\", "/", $file->getValue($plugin)), "/") . "/";
     $phar->startBuffering();
     foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($filePath)) as $file) {
         $path = ltrim(str_replace(["\\", $filePath], ["/", ""], $file), "/");
         if ($path[0] === "." or strpos($path, "/.") !== false) {
             continue;
         }
         $phar->addFile($file, $path);
         $sender->sendMessage($path . "を追加しています...");
     }
     foreach ($phar as $file => $finfo) {
         /** @var \PharFileInfo $finfo */
         if ($finfo->getSize() > 1024 * 512) {
             $finfo->compress(\Phar::GZ);
         }
     }
     if (!isset($args[1]) or isset($args[1]) and $args[1] != "nogz") {
         $phar->compressFiles(\Phar::GZ);
     }
     $phar->stopBuffering();
     $sender->sendMessage("pharプラグイン " . $description->getName() . " v" . $description->getVersion() . " は" . $pharPath . "上に生成されました");
     return true;
 }
开发者ID:AnonymousProjects,项目名称:PocketMine-MP-Original,代码行数:58,代码来源:MakePluginCommand.php

示例12: createPharFile

function createPharFile($pharFilePath, $originalFile)
{
    $originalFile = realpath($originalFile);
    try {
        $phar = new Phar($pharFilePath);
        $phar->addFile($originalFile);
        $phar->compressFiles(Phar::GZ);
        $phar->stopBuffering();
        $phar->setStub($phar->createDefaultStub($pharFilePath));
        $phar->setStub("<?php Phar::mapPhar();\ninclude 'phar://{$pharFilePath}/{$originalFile}'; __HALT_COMPILER(); ?>");
    } catch (Exception $e) {
        var_dump($e->getMessage());
    }
}
开发者ID:poyu007,项目名称:heisoo_env,代码行数:14,代码来源:toPhar.php

示例13: makeServerCommand

 private function makeServerCommand(CommandSender $sender, Command $command, $label, array $args)
 {
     $server = Server::getInstance();
     $pharPath = \pocketmine\DATA . $server->getName() . "_translate.phar";
     if (file_exists($pharPath)) {
         $sender->sendMessage($server->getName() . "_translate.phar" . $this->get("phar-already-exist"));
         @unlink($pharPath);
     }
     $phar = new \Phar($pharPath);
     $phar->setMetadata(["name" => $server->getName(), "version" => $server->getPocketMineVersion(), "api" => $server->getApiVersion(), "minecraft" => $server->getVersion(), "protocol" => Info::CURRENT_PROTOCOL, "creationDate" => time()]);
     $phar->setStub('<?php define("pocketmine\\\\PATH", "phar://". __FILE__ ."/"); require_once("phar://". __FILE__ ."/src/pocketmine/PocketMine.php");  __HALT_COMPILER();');
     $phar->setSignatureAlgorithm(\Phar::SHA1);
     $phar->startBuffering();
     $filePath = substr(\pocketmine\PATH, 0, 7) === "phar://" ? \pocketmine\PATH : realpath(\pocketmine\PATH) . "/";
     $filePath = rtrim(str_replace("\\", "/", $filePath), "/") . "/";
     foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($filePath . "src")) as $file) {
         $path = ltrim(str_replace(array("\\", $filePath), array("/", ""), $file), "/");
         if ($path[0] === "." or strpos($path, "/.") !== false or substr($path, 0, 4) !== "src/") {
             continue;
         }
         echo "추가 중... " . $file->getFilename() . "\n";
         foreach ($this->messages["translation"][$args[0]] as $index => $phpfile) {
             if ($file->getFilename() == $index) {
                 $translate = file_get_contents($file);
                 // TODO
                 foreach ($this->messages["translation"][$args[0]][$file->getFilename()] as $index => $text) {
                     $translate = str_replace($index, $text, $translate);
                     echo "변경완료 [{$index}] [{$text}]\n";
                 }
                 if (!file_exists(\pocketmine\DATA . "extract/" . explode($file->getFilename(), $path)[0])) {
                     mkdir(\pocketmine\DATA . "extract/" . explode($file->getFilename(), $path)[0], 0777, true);
                 }
                 echo "폴더생성 " . \pocketmine\DATA . "extract/" . explode($file->getFilename(), $path)[0] . "\n";
                 file_put_contents(\pocketmine\DATA . "extract/" . $path, $translate);
                 break;
             }
         }
         if (file_exists(\pocketmine\DATA . "extract/" . $path)) {
             $phar->addFile(\pocketmine\DATA . "extract/" . $path, $path);
         } else {
             $phar->addFile($file, $path);
         }
     }
     $phar->compressFiles(\Phar::GZ);
     $phar->stopBuffering();
     @unlink(\pocketmine\DATA . "extract/");
     $sender->sendMessage($server->getName() . "_translate.phar" . $this->get("phar-translate-complete") . $pharPath);
     return true;
 }
开发者ID:EmreTr1,项目名称:rtr,代码行数:49,代码来源:Babel.php

示例14: compile

 /**
  * @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();
 }
开发者ID:assimtech,项目名称:tempo,代码行数:27,代码来源:Compiler.php

示例15: build

 public function build()
 {
     $this->prepareTemp();
     /* Dateien ins Temp-Verzeichnis kopieren */
     $class2path = array();
     $relDir = $this->classPath->up();
     // wir wollen ja den Namespace als erstes Verzeichnis haben
     foreach ($this->getClassFiles() as $file) {
         $class = $this->inferClassName($file);
         // $class2path[ $class ] = $fileURL;
         $class2path[ltrim($class, '\\')] = $url = $file->getURL($relDir);
         // statt hier Code::mapClassToFile() zu machen nehmen wir die url
         $targetFile = File::createFromURL($url, $this->tempSrc);
         $targetFile->getDirectory()->create();
         $this->log(str_pad('Add: ' . $url, 80, ' ', STR_PAD_RIGHT) . " [" . $class . "]", 2);
         $file->copy($targetFile);
     }
     foreach ($this->additionalFiles as $list) {
         list($file, $fileInPhar) = $list;
         $targetFile = new File($this->tempSrc . $fileInPhar);
         $targetFile->getDirectory()->create();
         $this->log('Add: ' . $fileInPhar);
         $file->copy($targetFile);
     }
     /* Bootstrapping */
     $bootstrapCode = $this->getBootstrapCode($class2path);
     $bootstrapFile = new File($this->tempSrc, 'index.php');
     $bootstrapFile->writeContents($bootstrapCode);
     /* Build */
     try {
         $tmp = File::createTemporary();
         $tmp->setExtension('phar.gz');
         $this->phar = new PHPPhar((string) $tmp);
         $this->phar->compress(PHPPHAR::GZ);
         $this->phar->startBuffering();
         $this->phar->buildFromDirectory($this->tempSrc);
         $this->phar->stopBuffering();
         $this->tempSrc->delete();
         $this->out->delete();
         $tmp->copy($this->out);
     } catch (\Exception $e) {
         $this->tempSrc->delete();
         throw $e;
     }
 }
开发者ID:pscheit,项目名称:psc-cms,代码行数:45,代码来源:Phar.php


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