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


PHP Phar::convertToExecutable方法代码示例

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


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

示例1: init

 /**
  * Initialize the package creator
  */
 function init()
 {
     try {
         if (file_exists($this->path)) {
             @unlink($this->path);
         }
         $ext = strstr(strrchr($this->path, '-'), '.');
         if (!$ext) {
             $ext = strstr(strrchr($this->path, '/'), '.');
             if (!$ext) {
                 $ext = strstr(strrchr($this->path, '\\'), '.');
             }
         }
         if (!$ext) {
             $ext = strstr($this->path, '.');
         }
         $a = $this->_classname;
         $this->phar = new $a($this->path);
         if ($this->phar instanceof Phar) {
             $this->phar = $this->phar->convertToExecutable($this->format, $this->compression, $ext);
         } else {
             $this->phar = $this->phar->convertToData($this->format, $this->compression, $ext);
         }
         $this->phar->startBuffering();
         if ($this->phar instanceof Phar) {
             $this->phar->setStub($this->stub);
         }
         if ($this->format == Phar::ZIP) {
             $this->compression = $comp;
         }
     } catch (Exception $e) {
         throw new \Pyrus\Developer\Creator\Exception('Cannot open Phar archive ' . $this->path, $e);
     }
     $this->_started = false;
 }
开发者ID:peopleplan,项目名称:Pyrus,代码行数:38,代码来源:Phar.php

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

示例3: addslashes

echo $e->getMessage() . "\\n";
}
try {
Phar::mount("' . addslashes($pname) . '/testit1", "' . addslashes(__FILE__) . '");
} catch (Exception $e) {
echo $e->getMessage() . "\\n";
}
?>';
$a->setStub('<?php
set_include_path("phar://" . __FILE__);
include "index.php";
__HALT_COMPILER();');
Phar::mount($pname . '/testit1', __FILE__);
include $fname;
// test copying of a phar with mounted entries
$b = $a->convertToExecutable(Phar::TAR);
$b->setStub('<?php
set_include_path("phar://" . __FILE__);
include "index.php";
__HALT_COMPILER();');
try {
    include $fname2;
} catch (Exception $e) {
    echo $e->getMessage(), "\n";
}
try {
    Phar::mount($pname . '/oops', '/home/oops/../../etc/passwd:');
} catch (Exception $e) {
    echo $e->getMessage(), "\n";
}
Phar::mount($pname . '/testit2', $pname . '/testit1');
开发者ID:alphaxxl,项目名称:hhvm,代码行数:31,代码来源:phar_mount.php

示例4: Phar

#!/usr/bin/env php
<?php 
$file = __DIR__ . '/wukka-shortcircuit.phar';
@unlink($file . '.tar.gz');
$phar = new Phar($file);
$phar->buildFromDirectory(__DIR__ . '/lib/');
$phar->convertToExecutable(Phar::TAR, Phar::GZ);
开发者ID:wukka,项目名称:shortcircuit,代码行数:7,代码来源:create-phar.php

示例5: Phar

}
Phar::mungServer('hi');
Phar::createDefaultStub(array());
Phar::loadPhar(array());
Phar::canCompress('hi');
try {
    $a = new Phar(array());
} catch (TypeError $e) {
    print_exception($e);
}
try {
    $a = new Phar(dirname(__FILE__) . '/files/frontcontroller10.phar');
} catch (PharException $e) {
    print_exception($e);
}
$a->convertToExecutable(array());
$a->convertToData(array());
try {
    $b = new PharData(dirname(__FILE__) . '/whatever.tar');
} catch (PharException $e) {
    print_exception($e);
}
try {
    $c = new PharData(dirname(__FILE__) . '/whatever.zip');
} catch (PharException $e) {
    print_exception($e);
}
$b->delete(array());
try {
    $a->delete('oops');
} catch (Exception $e) {
开发者ID:zaky-92,项目名称:php-1,代码行数:31,代码来源:ext_phar_tests_badparameters.php

示例6: realpath

<?php

define('PREFIX', 'orm-generator');
define('PHAR_FILE', PREFIX . '.phar');
define('PHAR_OUTPUT', 'bin' . DIRECTORY_SEPARATOR . PHAR_FILE);
define('DEFAULT_STUB', 'phar-generate.php');
define('BUILD_DIR', realpath(__DIR__ . '/build'));
define('INCLUDE_EXTENSION', '/\\.php$/');
try {
    if (file_exists(PHAR_OUTPUT)) {
        unlink(PHAR_OUTPUT);
    }
    /****************************************
     * phar file creation
     ****************************************/
    $tarphar = new Phar(PHAR_OUTPUT);
    $phar = $tarphar->convertToExecutable(Phar::PHAR);
    $phar->startBuffering();
    $phar->buildFromDirectory(BUILD_DIR, INCLUDE_EXTENSION);
    $stub = $phar->createDefaultStub(DEFAULT_STUB);
    $phar->setStub("#!/usr/bin/php\n" . $stub);
    $phar->stopBuffering();
} catch (Exception $e) {
    echo $e;
}
开发者ID:pedro151,项目名称:orm-generator,代码行数:25,代码来源:create-phar.php

示例7: array

#!/usr/bin/php
<?php 
// Build script to create firewall phars.  This is required to be distributed to
// remain in compliance with Section 1 of the AGPL. This is defined as a
// 'Corresponding Source' of the Firewall module, as it is required to build the
// service.
$apps = array("voipfirewalld" => array("firewall.php", "common.php", array(__DIR__ . "/../hooks/validator.php", "validator.php"), array(__DIR__ . "/../Lock.class.php", "lock.php"), "modprobe.php"));
$dst = __DIR__ . "/../hooks/";
foreach ($apps as $app => $files) {
    $outfile = "{$app}.phar";
    print "Building {$outfile} ... ";
    @unlink($outfile);
    $phar = new Phar($outfile, 0, "{$app}.phar");
    $phar->convertToExecutable(Phar::TAR);
    $phar->startBuffering();
    foreach ($files as $f) {
        if (is_array($f)) {
            $src = $f[0];
            $dest = $f[1];
        } else {
            $src = __DIR__ . "/src/{$f}";
            $dest = $f;
        }
        $phar->addFile($src, $dest);
    }
    $start = $files[0];
    // Note that ? and > are broken apart to stop syntax highlighting from getting confused.
    $stub = "#!/usr/bin/env php\n<?php\n\$s='{$start}';\$f=__FILE__;Phar::interceptFileFuncs();set_include_path(\"phar://\$f/\".get_include_path());Phar::webPhar(null, \$s);include \"phar://\$f/\$s\";__HALT_COMPILER(); ?" . ">\n";
    $phar->setStub($stub);
    $phar->compressFiles(Phar::BZ2);
    $phar->stopBuffering();
开发者ID:ntadmin,项目名称:firewall,代码行数:31,代码来源:build.php


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