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


PHP Phar::addFile方法代码示例

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


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

示例1: addFile

 public function addFile($path, $localName = '')
 {
     try {
         if ($localName == '') {
             $this->_phar->addFile($path);
         } else {
             $this->_phar->addFile($path, $localName);
         }
     } catch (PharException $e) {
         throw new RuntimeException('File add failed: ' . (string) $e);
     }
 }
开发者ID:jhartikainen,项目名称:packageizer,代码行数:12,代码来源:Phar.php

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

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

示例4: testItExtractsIconFromPhar

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

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

示例6: create

 /**
  * Creates a PHP archive file with all files necessary to
  * run Environaut standalone.
  *
  * @param string $phar_path full path to the php archive file to create
  */
 public function create($phar_path = 'environaut.phar')
 {
     if (file_exists($phar_path)) {
         unlink($phar_path);
     }
     $phar = new \Phar($phar_path, 0, 'environaut.phar');
     $phar->setSignatureAlgorithm(\Phar::SHA1);
     $phar->startBuffering();
     $root_dir = dirname(dirname(__DIR__));
     // add environaut files
     $finder = new Finder();
     $finder->files()->notName('PharCompiler.php')->in($root_dir . '/src');
     foreach ($finder as $file) {
         $phar->addFile($file->getRealPath(), 'src/' . $file->getRelativePathname());
     }
     // add vendor files using a whitelist with excludes
     $finder = new Finder();
     $finder->files()->name('*.php')->name('security\\.sensiolabs\\.org\\.crt')->path('/symfony\\/console\\//')->path('/sensiolabs\\/security-checker\\//')->notName('SecurityCheckerCommand.php')->notPath('/(\\/Tests\\/|\\/Tester\\/)/')->in($root_dir . '/vendor');
     foreach ($finder as $file) {
         $phar->addFile($file->getRealPath(), 'vendor/' . $file->getRelativePathname());
     }
     // add composer vendor autoloading
     $vendor_root_dir = $root_dir . '/vendor/';
     $phar->addFile($vendor_root_dir . 'autoload.php', 'vendor/autoload.php');
     $composer_dir = $vendor_root_dir . 'composer/';
     $phar->addFile($composer_dir . 'autoload_namespaces.php', 'vendor/composer/autoload_namespaces.php');
     $phar->addFile($composer_dir . 'autoload_classmap.php', 'vendor/composer/autoload_classmap.php');
     $phar->addFile($composer_dir . 'autoload_psr4.php', 'vendor/composer/autoload_psr4.php');
     $phar->addFile($composer_dir . 'autoload_real.php', 'vendor/composer/autoload_real.php');
     //$phar->addFile($composer_dir . 'include_paths.php', 'vendor/composer/include_paths.php');
     $phar->addFile($composer_dir . 'ClassLoader.php', 'vendor/composer/ClassLoader.php');
     // environaut executable
     $phar->addFile($root_dir . '/bin/environaut', 'bin/environaut');
     // additional markdown files like README.md or LICENSE.md
     $finder = new Finder();
     $finder->files()->name('*.md')->depth('== 0')->in($root_dir);
     foreach ($finder as $file) {
         $phar->addFile($file->getRealPath(), '/' . $file->getRelativePathname());
     }
     // add startup file
     $phar->setStub($this->getStub());
     $phar->stopBuffering();
     chmod($phar_path, 0755);
 }
开发者ID:graste,项目名称:environaut,代码行数:50,代码来源:PharCompiler.php

示例7: addRecr

 public function addRecr($dir, $localName)
 {
     $localName = rtrim($localName, "/\\") . "/";
     foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir)) as $file) {
         if (!is_file($file)) {
             continue;
         }
         $shortPath = str_replace("\\", "/", ltrim(substr($file, strlen($dir)), "/\\"));
         // Why, Windows...
         $this->pharObj->addFile($file, $localName . $shortPath);
     }
 }
开发者ID:GoneTone,项目名称:web-server-source,代码行数:12,代码来源:PharBuilder.php

示例8: compile

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

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

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

示例11: pack

    public function pack()
    {
        if (file_exists(self::NAME)) {
            \Phar::unlinkArchive(self::NAME);
        }
        $phar = new \Phar(self::NAME);
        // Stub
        $code = <<<'EOC'
#! /usr/bin/env php
<?php

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

define('PHPMIG_PHAR', true);
require 'phar://phpmig.phar/vendor/autoload.php';
$app = new PhpMigration\App();
$app->run();

__HALT_COMPILER();
EOC;
        $phar->setStub($code);
        // File
        foreach ($this->filelist as $file) {
            $phar->addFile($file);
        }
        // Vendor
        chdir(__DIR__ . '/../../');
        $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator('vendor'), 0, \RecursiveIteratorIterator::CATCH_GET_CHILD);
        foreach ($iterator as $file) {
            if (!preg_match('/\\/(\\.|test\\/)/i', $file)) {
                $phar->addFile($file);
            }
        }
        // Add execute permission
        chmod(self::NAME, 0755);
    }
开发者ID:monque,项目名称:php-migration,代码行数:36,代码来源:Packager.php

示例12: execute

 /**
  * {@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;
 }
开发者ID:kzykhys,项目名称:coupe,代码行数:47,代码来源:PharCommand.php

示例13: addDir

function addDir(Phar $phar, $from, $localDir)
{
    global $i;
    $from = rtrim(realpath($from), "/") . "/";
    $localDir = rtrim($localDir, "/") . "/";
    if (!is_dir($from)) {
        echo "WARNING: {$from} is not a directory!";
        return;
    }
    /** @type SplFileInfo $file */
    foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($from)) as $file) {
        if (!$file->isFile()) {
            continue;
        }
        $incl = substr($file, strlen($from));
        $targ = $localDir . $incl;
        $phar->addFile($file, $targ);
        $i++;
    }
}
开发者ID:gitter-badger,项目名称:DynamicHub,代码行数:20,代码来源:compile.php

示例14: execute

 public function execute(CommandSender $sender, $commandLabel, array $args)
 {
     if (!$this->testPermission($sender)) {
         return false;
     }
     $server = $sender->getServer();
     $pharPath = Server::getInstance()->getPluginPath() . DIRECTORY_SEPARATOR . "PocketMine-MO" . DIRECTORY_SEPARATOR . $server->getName() . "_" . $server->getPocketMineVersion() . ".phar";
     if (file_exists($pharPath)) {
         $sender->sendMessage("pharファイルが既に存在しているため、上書きします");
         @unlink($pharPath);
     }
     $phar = new \Phar($pharPath);
     $phar->setMetadata(["name" => $server->getName(), "version" => $server->getPocketMineVersion(), "api" => $server->getApiVersion(), "geniapi" => $server->getGeniApiVersion(), "minecraft" => $server->getVersion(), "protocol" => Info::CURRENT_PROTOCOL, "creator" => "PocketMine-MO MakeServerCommand", "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(["\\", $filePath], ["/", ""], $file), "/");
         if ($path[0] === "." or strpos($path, "/.") !== false or substr($path, 0, 4) !== "src/") {
             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[0]) or isset($args[0]) and $args[0] != "nogz") {
         $phar->compressFiles(\Phar::GZ);
     }
     $phar->stopBuffering();
     $sender->sendMessage($server->getName() . " " . $server->getPocketMineVersion() . "のpharファイルが" . $pharPath . "に生成されました");
     return true;
 }
开发者ID:AnonymousProjects,项目名称:PocketMine-MP-Original,代码行数:39,代码来源:MakeServerCommand.php

示例15: addDir

function addDir(\Phar $phar, $realPath, $localPath)
{
    global $i;
    $realPath = str_replace("\\", "/", $realPath);
    $localPath = rtrim($localPath, "/\\") . "/";
    echo "Directory transfer: {$realPath} > {$localPath}", PHP_EOL;
    foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($realPath)) as $path) {
        if (!$path->isFile()) {
            continue;
        }
        $path = str_replace("\\", "/", (string) $path);
        if (strpos($path, ".git") !== false) {
            continue;
        }
        $relative = ltrim(substr($path, strlen($realPath)), "/");
        $local = $localPath . $relative;
        $num = str_pad((string) ++$i, 3, "0", STR_PAD_LEFT);
        echo "\r[{$num}] Adding: " . realpath($path) . " to {$local}";
        $phar->addFile($path, $local);
    }
    echo "\n";
}
开发者ID:WonderlandPE,项目名称:WorldEditArt,代码行数:22,代码来源:make.php


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