sevenpercent / phar-compiler
Compiles a CLI PHP project into a self-executing Phar archive
Installs: 9
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
pkg:composer/sevenpercent/phar-compiler
Requires
- php: >=7.2.0
- ext-phar: *
This package is not auto-updated.
Last update: 2025-12-21 10:44:51 UTC
README
Compiles a CLI PHP project into a self-executing Phar archive.
Usage
Assuming a project structure as follows...
$ 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():
<?php declare(strict_types = 1); use SevenPercent\PharCompiler; require_once 'vendor/autoload.php'; PharCompiler::compile('bin/foo', 'build/', [ 'src/', 'vendor/', ]);