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


PHP Phar::running方法代码示例

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


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

示例1: generate

    /**
     * Generate a new Job script to be executed under a separate PHP process
     *
     * @param null|string   $mutantFile
     * @param array         $args
     * @param string        $bootstrap
     * @param null|string   $replacingFile
     * @return string
     */
    public static function generate($mutantFile = null, $bootstrap = '', $replacingFile = null)
    {
        if ('phar:' === substr(__FILE__, 0, 5)) {
            $humbugBootstrap = \Phar::running() . '/bootstrap.php';
        } else {
            $humbugBootstrap = realpath(__DIR__ . '/../../../bootstrap.php');
        }
        $file = sys_get_temp_dir() . '/humbug.phpunit.bootstrap.php';
        if (!is_null($mutantFile)) {
            $mutantFile = addslashes($mutantFile);
            $replacingFile = addslashes($replacingFile);
            $prepend = <<<PREPEND
<?php
require_once '{$humbugBootstrap}';
use Humbug\\StreamWrapper\\IncludeInterceptor;
IncludeInterceptor::intercept('{$replacingFile}', '{$mutantFile}');
IncludeInterceptor::enable();
PREPEND;
            if (!empty($bootstrap)) {
                $buffer = $prepend . "\nrequire_once '{$bootstrap}';";
            } else {
                $buffer = $prepend;
            }
            file_put_contents($file, $buffer);
        } else {
            if (!empty($bootstrap)) {
                $buffer = "<?php\nrequire_once '{$humbugBootstrap}';\nrequire_once '{$bootstrap}';";
            } else {
                $buffer = "<?php\nrequire_once '{$humbugBootstrap}';";
            }
            file_put_contents($file, $buffer);
        }
    }
开发者ID:shadowhand,项目名称:humbug,代码行数:42,代码来源:Job.php

示例2: __construct

 /**
  * Initializes all components used by phpDocumentor.
  *
  * @param ClassLoader $autoloader
  * @param array       $values
  */
 public function __construct($autoloader = null, array $values = array())
 {
     $this->defineIniSettings();
     self::$VERSION = strpos('@package_version@', '@') === 0 ? trim(file_get_contents(__DIR__ . '/../../VERSION')) : '@package_version@';
     parent::__construct('phpDocumentor', self::$VERSION, $values);
     $this['kernel.timer.start'] = time();
     $this['kernel.stopwatch'] = function () {
         return new Stopwatch();
     };
     $this['autoloader'] = $autoloader;
     $this->register(new JmsSerializerServiceProvider());
     $this->register(new Configuration\ServiceProvider());
     $this->addEventDispatcher();
     $this->addLogging();
     $this->register(new ValidatorServiceProvider());
     $this->register(new Translator\ServiceProvider());
     $this->register(new Descriptor\ServiceProvider());
     $this->register(new Parser\ServiceProvider());
     $this->register(new Partials\ServiceProvider());
     $this->register(new Transformer\ServiceProvider());
     $this->register(new Plugin\ServiceProvider());
     $this->addCommandsForProjectNamespace();
     if (\Phar::running()) {
         $this->addCommandsForPharNamespace();
     }
 }
开发者ID:axelmdev,项目名称:ecommerce,代码行数:32,代码来源:Application.php

示例3: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $manifest = $input->getOption('manifest') ?: 'https://platform.sh/cli/manifest.json';
     $currentVersion = $input->getOption('current-version') ?: $this->getApplication()->getVersion();
     if (extension_loaded('Phar') && !($localPhar = \Phar::running(false))) {
         $this->stdErr->writeln('This instance of the CLI was not installed as a Phar archive.');
         if (file_exists(CLI_ROOT . '/../../autoload.php')) {
             $this->stdErr->writeln('Update using: <info>composer global update</info>');
         }
         return 1;
     }
     $manager = new Manager(Manifest::loadFile($manifest));
     if (isset($localPhar)) {
         $manager->setRunningFile($localPhar);
     }
     $onlyMinor = !$input->getOption('major');
     $updated = $manager->update($currentVersion, $onlyMinor);
     if ($updated) {
         $this->stdErr->writeln("Successfully updated");
         $localPhar = $manager->getRunningFile();
         passthru('php ' . escapeshellarg($localPhar) . ' --version');
     } else {
         $this->stdErr->writeln("No updates found. The Platform.sh CLI is up-to-date.");
     }
     return 0;
 }
开发者ID:joshmiller83,项目名称:platformsh-cli,代码行数:26,代码来源:SelfUpdateCommand.php

示例4: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $application = $this->getApplication();
     $manifest = $input->getOption('manifest') ?: 'http://drupalconsole.com/manifest.json';
     $currentVersion = $input->getOption('current-version') ?: $application->getVersion();
     $major = $input->getOption('major');
     if (!extension_loaded('Phar') || !\Phar::running(false)) {
         $io->error($this->trans('commands.self-update.messages.not-phar'));
         $io->block($this->trans('commands.self-update.messages.instructions'));
         return 1;
     }
     $io->info(sprintf($this->trans('commands.self-update.messages.check'), $currentVersion));
     $updater = new Updater(null, false);
     $strategy = new ManifestStrategy($currentVersion, $major, $manifest);
     $updater->setStrategyObject($strategy);
     if (!$updater->hasUpdate()) {
         $io->info(sprintf($this->trans('commands.self-update.messages.current-version'), $currentVersion));
         return 0;
     }
     $oldVersion = $updater->getOldVersion();
     $newVersion = $updater->getNewVersion();
     if (!$io->confirm(sprintf($this->trans('commands.self-update.questions.update'), $oldVersion, $newVersion), true)) {
         return 1;
     }
     $io->comment(sprintf($this->trans('commands.self-update.messages.update'), $newVersion));
     $updater->update();
     $io->success(sprintf($this->trans('commands.self-update.messages.success'), $oldVersion, $newVersion));
     // Errors appear if new classes are instantiated after this stage
     // (namely, Symfony's ConsoleTerminateEvent). This suggests PHP
     // can't read files properly from the overwritten Phar, or perhaps it's
     // because the autoloader's name has changed. We avoid the problem by
     // terminating now.
     exit;
 }
开发者ID:blasoliva,项目名称:DrupalConsole,代码行数:38,代码来源:UpdateCommand.php

示例5: selfupdate

function selfupdate($argv, $inPhar)
{
    $opts = ['http' => ['method' => 'GET', 'header' => "User-agent: phpfmt fmt.phar selfupdate\r\n"]];
    $context = stream_context_create($opts);
    // current release
    $releases = json_decode(file_get_contents('https://api.github.com/repos/phpfmt/fmt/tags', false, $context), true);
    $commit = json_decode(file_get_contents($releases[0]['commit']['url'], false, $context), true);
    $files = json_decode(file_get_contents($commit['commit']['tree']['url'], false, $context), true);
    foreach ($files['tree'] as $file) {
        if ('fmt.phar' == $file['path']) {
            $phar_file = base64_decode(json_decode(file_get_contents($file['url'], false, $context), true)['content']);
        }
        if ('fmt.phar.sha1' == $file['path']) {
            $phar_sha1 = base64_decode(json_decode(file_get_contents($file['url'], false, $context), true)['content']);
        }
    }
    if (!isset($phar_sha1) || !isset($phar_file)) {
        fwrite(STDERR, 'Could not autoupdate - not release found' . PHP_EOL);
        exit(255);
    }
    if ($inPhar && !file_exists($argv[0])) {
        $argv[0] = dirname(Phar::running(false)) . DIRECTORY_SEPARATOR . $argv[0];
    }
    if (sha1_file($argv[0]) != $phar_sha1) {
        copy($argv[0], $argv[0] . '~');
        file_put_contents($argv[0], $phar_file);
        chmod($argv[0], 0777 & ~umask());
        fwrite(STDERR, 'Updated successfully' . PHP_EOL);
        exit(0);
    }
    fwrite(STDERR, 'Up-to-date!' . PHP_EOL);
    exit(0);
}
开发者ID:straiway,项目名称:fmt,代码行数:33,代码来源:selfupdate.php

示例6: realpath

 /**
  * CodeSniffer alternative for realpath.
  *
  * Allows for PHAR support.
  *
  * @param string $path The path to use.
  *
  * @return mixed
  */
 public static function realpath($path)
 {
     // Support the path replacement of ~ with the user's home directory.
     if (substr($path, 0, 2) === '~/') {
         $homeDir = getenv('HOME');
         if ($homeDir !== false) {
             $path = $homeDir . substr($path, 1);
         }
     }
     // No extra work needed if this is not a phar file.
     if (self::isPharFile($path) === false) {
         return realpath($path);
     }
     // Before trying to break down the file path,
     // check if it exists first because it will mostly not
     // change after running the below code.
     if (file_exists($path) === true) {
         return $path;
     }
     $phar = \Phar::running(false);
     $extra = str_replace('phar://' . $phar, '', $path);
     $path = realpath($phar);
     if ($path === false) {
         return false;
     }
     $path = 'phar://' . $path . $extra;
     if (file_exists($path) === true) {
         return $path;
     }
     return false;
 }
开发者ID:thekabal,项目名称:tki,代码行数:40,代码来源:Common.php

示例7: isPhar

 /**
  * Running from Phar or not?
  *
  * @return bool
  */
 public static function isPhar()
 {
     if (!empty(\Phar::running())) {
         self::$pharPath = \Phar::running();
         return true;
     }
     return false;
 }
开发者ID:narno,项目名称:phpoole,代码行数:13,代码来源:Plateform.php

示例8: phargui_autoloader

function phargui_autoloader($class_name)
{
    $file = str_replace('\\', '/', $class_name) . '.php';
    if (Phar::running()) {
        include 'phar://phar-gui.phar/lib/' . $file;
    } else {
        include __DIR__ . '/' . $file;
    }
}
开发者ID:sdgdsffdsfff,项目名称:phar-gui,代码行数:9,代码来源:autoload.php

示例9: getRoot

 public function getRoot($external = false)
 {
     if ($external && \Phar::running(false) != "") {
         return dirname(\Phar::running(false));
     }
     if (!$this->root && !defined('MANIALIB_APP_PATH')) {
         throw new \Exception();
     }
     return $this->root ?: MANIALIB_APP_PATH;
 }
开发者ID:kremsy,项目名称:manialib,代码行数:10,代码来源:Path.php

示例10: __construct

 public function __construct()
 {
     parent::__construct('Feather', self::VERSION);
     $this->add(new Command\RunCommand());
     if (\Phar::running()) {
         $command = new AmendCommand('self-update');
         $command->setManifestUri('http://zroger.github.io/feather/manifest.json');
         $this->getHelperSet()->set(new AmendHelper());
         $this->add($command);
     }
 }
开发者ID:zroger,项目名称:feather,代码行数:11,代码来源:Application.php

示例11: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (ini_get('allow_url_fopen') !== '1') {
         throw new \RuntimeException('`allow_url_fopen` must be enabled in your php.ini to use the `self-update` command.');
     }
     $phar = preg_replace('/^phar:\\/\\//', '', \Phar::running());
     $output->writeln('Overwriting ' . $phar);
     if (!is_writable($phar)) {
         throw new \RuntimeException('The Phar path is not writable. Ensure permissions are set to allow the file to be written to.');
     }
     $latest = file_get_contents('http://mongrate.com/download?self-update&from=' . MONGRATE_VERSION);
     file_put_contents($phar, $latest);
 }
开发者ID:nilopc-interesting-libs,项目名称:mongrate,代码行数:13,代码来源:SelfUpdateCommand.php

示例12: getDefaultCommands

 protected function getDefaultCommands()
 {
     $commands = parent::getDefaultCommands();
     $commands[] = new Command\ValidateCommand();
     $commands[] = new Command\ConvertCommand();
     $commands[] = new Command\ReleaseCommand();
     $commands[] = new Command\InstallerCommand();
     $commands[] = new Command\InfoCommand();
     if (\Phar::running() !== '') {
         $commands[] = new Command\SelfUpdateCommand();
     }
     return $commands;
 }
开发者ID:jingdor,项目名称:pickle,代码行数:13,代码来源:Application.php

示例13: curdir

function curdir()
{
    $trace = debug_backtrace(0, 1);
    $dir = dirname($trace[0]['file']);
    $phar = \Phar::running(false);
    if (empty($phar)) {
        return $dir;
    }
    $dir = str_replace('phar://', '', $dir);
    $dir = str_replace($phar, '', $dir);
    $dir = str_replace(dirname($phar), '', $dir);
    return \Phar::running() . $dir;
}
开发者ID:encorephp,项目名称:kernel,代码行数:13,代码来源:helpers.php

示例14: extractFile

 /**
  * Extract the file from the phar archive to make it accessible for native commands.
  *
  * @param string $filePath  the absolute file path to extract
  * @param bool   $overwrite
  *
  * @return string
  */
 public static function extractFile($filePath, $overwrite = false)
 {
     $pharPath = \Phar::running(false);
     if (empty($pharPath)) {
         return '';
     }
     $relativeFilePath = substr($filePath, strpos($filePath, $pharPath) + strlen($pharPath) + 1);
     $tmpDir = sys_get_temp_dir() . '/jolinotif';
     $extractedFilePath = $tmpDir . '/' . $relativeFilePath;
     if (!file_exists($extractedFilePath) || $overwrite) {
         $phar = new \Phar($pharPath);
         $phar->extractTo($tmpDir, $relativeFilePath, $overwrite);
     }
     return $extractedFilePath;
 }
开发者ID:jeremyFreeAgent,项目名称:JoliNotif,代码行数:23,代码来源:PharExtractor.php

示例15: __construct

 /**
  * Setting up the system, setting parameters.
  */
 public function __construct()
 {
     if (function_exists('ini_set') && extension_loaded('xdebug')) {
         ini_set('xdebug.show_exception_trace', false);
         ini_set('xdebug.scream', false);
     }
     if (function_exists('date_default_timezone_set') && function_exists('date_default_timezone_get')) {
         date_default_timezone_set(@date_default_timezone_get());
     }
     if (stripos(\Phar::running(), 'phar:') !== false) {
         Config::$path = '/var/phpcron/';
     }
     $this->createPatch();
     Config::$sharedId = shm_attach(ftok(__FILE__, 'A'));
     parent::__construct(strtolower(Config::NAME), Config::VERSION);
 }
开发者ID:dmamontov,项目名称:symfony-phpcron,代码行数:19,代码来源:Application.php


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