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 |
--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
*.php
files fromsrc/
andvendor/
dirs - Define
main.php
as 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
*.php
and*.phtml
files fromsrc/
dir - Define
main.php
as 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.php
as the stub main entrypoint script - Save compiled phar executable to
foobar.phar
- Use
LICENSE
file contents as legal notice banner
phpcc -e app.php -o foobar.phar -b LICENSE
- Define
app.php
as the stub main entrypoint script - Save compiled phar executable to
foobar.phar
- Add
foo.php
andbar.php
files to the archive
phpcc -e app.php -o foobar.phar -f foo.php -f bar.php
- Define
app.php
as the stub main entrypoint script - Save compiled phar executable to
bin/acme
- Add the
license
&author
metadata to the archive
phpcc -e app.php -o bin/acme -m license:MIT -m author:yannoff
php
orpaw
7.1+phar.readonly
php 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/phpcc
Add execution permissions to the binary
chmod +x ${BINDIR}/phpcc
Licensed under the MIT License.