Skip to content

Instantly share code, notes, and snippets.

@jjsty1e
Created June 9, 2021 10:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jjsty1e/bd310a3cc1c62cb1c9adfc25b9c6893a to your computer and use it in GitHub Desktop.
Save jjsty1e/bd310a3cc1c62cb1c9adfc25b9c6893a to your computer and use it in GitHub Desktop.
build-phar
<?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