19/10
2017
Compiles a CLI PHP project into a self-executing Phar archive
Compiles a CLI PHP project into a self-executing Phar archive., (*1)
Assuming a project structure as follows..., (*3)
$ pwd /home/steven.hilder/foo $ tree โโโ bin โ โโโ foo โโโ src โ โโโ MyClass1.php โ โโโ MyClass2.php โโโ vendor โโโ autoload.php โโโ composer โโโ ...
...where bin/foo
is the executable entry point to your CLI application; you can compile the project by passing
the executable, target build directory and array of include directories to SevenPercent\PharCompiler::compile()
:, (*4)
<?php declare(strict_types = 1); use SevenPercent\PharCompiler; require_once 'vendor/autoload.php'; PharCompiler::compile('bin/foo', 'build/', [ 'src/', 'vendor/', ]);