micro SAPI makes PHP self-executable, allowing you to run php-cli apps without any PHP installation.

———
micro is a SAPI module for PHP that allows you to create self-executable PHP binaries. By concatenating the micro SAPI binary with your PHP source code or PHAR files, you can run PHP applications without requiring a separate PHP installation.
micro SAPI works similarly to the built-in CLI SAPI, you can run almost all CLI-based PHP applications with it.
Quick Start
We recommend building micro SAPI using
to include popular extensions like pdo, openssl, mbstring, and more.
You can first try
from hosted by static-php.dev server:
PlatformDownload LinkLinux x86_64
Linux aarch64
Windows x86_64
macOS x86_64
macOS arm64
Then prepare your PHP code or PHAR cli app archive, and concatenate them:
<?php// myapp.phpecho"Hello, this is my awesome app." . PHP_EOL;# On Linux/macOS: cat /path/to/micro.sfx myapp.php > myapp chmod +x ./myapp ./myapp # shows "Hello, this is my awesome app."# or on Windows: COPY /b \path\to\micro.sfx + myapp.php myapp.exe .\myapp.exe # shows "Hello, this is my awesome app."Build statically linked micro.sfx
Since we need to build micro.sfx as a standalone and portable binary, the best way is to build it statically. That will make sure it can run on most systems without worrying about missing shared libraries.
You can follow the steps in static-php.dev docs to build your own static PHP binary with micro SAPI included:
First, download and install static-php-cli by following the
.
Next, use the spc command to build a static PHP binary with micro SAPI:
# linux/macOS EXTENSIONS="bcmath,phar,openssl,mbstring" ./spc doctor --auto-fix ./spc download --for-extensions=$EXTENSIONS --with-php=8.4 ./spc build $EXTENSIONS --build-micro # windows (PowerShell) .\spc.exe doctor --auto-fix .\spc.exe download --for-extensions="bcmath,phar,openssl,mbstring" --with-php=8.4 .\spc.exe build "bcmath,phar,openssl,mbstring" --build-microDocumentation
For more details about micro SAPI, please refer to the
docs.
Credit
This project originally forked from
and adapted to work with static-php-cli.
Thanks to all the contributors of phpmicro and static-php-cli projects.
Open-Source License
This project is licensed under Apache-2.0 License. See the
file for details.
When building static PHP with static-php-cli, the resulting binary may include other open-source components. Please refer to the
description.