Skip to content

Instantly share code, notes, and snippets.

@jasdeepkhalsa
Last active November 28, 2020 16:30
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 jasdeepkhalsa/21c5e1759a4fb9afd9385f0cb281ac20 to your computer and use it in GitHub Desktop.
Save jasdeepkhalsa/21c5e1759a4fb9afd9385f0cb281ac20 to your computer and use it in GitHub Desktop.
Create PHAR
#!/usr/bin/env php
<?php
$phar = null;
try {
$file = "dbdiff.phar";
$phar = new Phar('./' . $file, FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::KEY_AS_FILENAME, $file);
$phar["index.php"] = file_get_contents("./dbdiff");
$phar->buildFromDirectory("./src",'/.php$/');
$phar->setStub($phar->createDefaultStub('index.php'));
} catch (Exception $e) {
echo "The following error occurred and a PHAR archive could not be produced:\n" . $e;
}
echo var_dump($phar->getStub());
echo file_get_contents($file);
# Disable PHAR readonly for producing PHAR archives
RUN echo 'phar.readonly=0' >> /usr/local/etc/php/conf.d/docker-php-phar-readonly.ini
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment