PHP Code compiler - Phar executable compiling utility
phpcc --help
phpcc --version
phpcc \
-e <main> \
-o <output> \
[-d <dir> [-d <dir> ...]] \
[-f <file> [-f <file> ...]] \
[-b <banner>] \
[-m <metadata> [-m <metadata> ...]]
The output and entrypoint scripts are mandatory.
| Name / Shorthand | Type | Description | Required |
|---|---|---|---|
--output, -o |
value | The Phar archive output file | y |
--main, -e |
value | The main application entrypoint script | y |
--banner, -b |
value | Specify the filepath to the legal notice banner Will be included in the human-readable part of the stub. |
n |
--file, -f |
multi | Adds a single file to the archive | n |
--dir, -d |
multi | Adds a sources directory to the archive Possible dir spec formats: - $dir => include all files in directory- $dir:$extension => filter files on a specific extension |
n |
--meta, -m |
multi | Adds a metadata to the archive Metadata must be specified in the $key:$value format |
n |
--no-minify, -n |
flag | Don't minify PHP source files Useful for debugging the compiled executable in case of runtime errors |
n |
--shebang-less |
flag | Produce a stub deprived of the shebang directive Useful when the phar is meant to be included instead of being executed directly |
n |
--quiet, -q |
flag | Reduce output messages amount: set verbosity level to INFO instead of default DEBUG |
n |
phpcc -d src:php -d vendor:php -e bin/compile.php -o bin/phpcc -b .banner- Add all
*.phpfiles fromsrc/andvendor/dirs - Define
main.phpas the stub main entrypoint script - Save compiled phar executable to
bin/foobar
phpcc -d src:php -d vendor:php -e main.php -o bin/foobar- Add all
*.phpand*.phtmlfiles fromsrc/dir - Define
main.phpas the stub main entrypoint script - Save compiled phar executable to
bin/foobar
phpcc -d src:php -d src:phtml -e main.php -o bin/foobar- Define
app.phpas the stub main entrypoint script - Save compiled phar executable to
foobar.phar - Use
LICENSEfile contents as legal notice banner
phpcc -e app.php -o foobar.phar -b LICENSE- Define
app.phpas the stub main entrypoint script - Save compiled phar executable to
foobar.phar - Add
foo.phpandbar.phpfiles to the archive
phpcc -e app.php -o foobar.phar -f foo.php -f bar.php- Define
app.phpas the stub main entrypoint script - Save compiled phar executable to
bin/acme - Add the
license&authormetadata to the archive
phpcc -e app.php -o bin/acme -m license:MIT -m author:yannoffphporpaw7.1+phar.readonlyphp config directive must be set toOff
Get the latest release from Github
💡
${BINDIR}may be /usr/bin, /usr/local/bin or $HOME/bin
curl -Lo ${BINDIR}/phpcc https://github.com/yannoff/phpcc/releases/latest/download/phpccAdd execution permissions to the binary
chmod +x ${BINDIR}/phpccLicensed under the MIT License.