Created
June 9, 2021 10:02
-
-
Save jjsty1e/bd310a3cc1c62cb1c9adfc25b9c6893a to your computer and use it in GitHub Desktop.
build-phar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$pharFile = 'bin/fanyi.phar'; | |
if (file_exists($pharFile)) { | |
unlink($pharFile); | |
} | |
$phar = new Phar($pharFile); | |
$phar->startBuffering(); | |
$defaultStub = $phar->createDefaultStub('index.php'); | |
$phar->buildFromDirectory(__DIR__, '/\.php$/'); | |
$phar->addFile('lib/source.json'); | |
$phar->setStub('#!/usr/bin/env php' . PHP_EOL . $defaultStub); | |
$phar->stopBuffering(); | |
$phar->compressFiles(Phar::GZ); | |
chmod($pharFile, 0770); | |
echo 'phar successfully created' . PHP_EOL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment