Skip to content

Instantly share code, notes, and snippets.

@GaryRogers GaryRogers/createPhar.php
Last active Dec 23, 2018

What would you like to do?
Create a Phar archive for PHP
# Create an executable phar
# Name of our archive.
$phar = new Phar("myscript.phar");
# Have to do buffering to make things executable.
# See
# Default executable.
$defaultStub = $phar->createDefaultStub('bin/myscript.php');
# Build from the project directory. Assumes that createPhar.php (this file) is in the project root.
# Add the header to enable execution.
$stub = "#!/usr/bin/env php \n" . $defaultStub;
# Set the stub.
# Wrap up.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.