| title | Distribute as a single executable binary |
|---|---|
| description | Build a standalone executable binary to distribute your project without requiring PHP or dependencies on target systems |
Your Laravel Zero project can be bundled into a standalone executable binary that runs on target systems without requiring PHP, Composer, or any other dependencies to be pre-installed.
We use PHPacker to create self-contained binaries from your PHAR archives.
First, add PHPacker as a development dependency:
composer require phpacker/phpacker --devBefore creating the binary, you need to build your PHAR archive. The build name must have the .phar extension:
php <your-app-name> app:build <your-build-name>.pharOnce your PHAR archive is ready in the builds folder, create binaries for all supported platforms:
./vendor/bin/phpacker build --src=./builds/<your-build-name>.phar --php=8.4 allThis command builds binaries with PHP 8.4 embedded for:
- macOS: arm64 and x64 architectures
- Linux: arm64 and x64 architectures
- Windows: x64 architecture
The binaries will be created in the ./builds/build folder, organized by platform.
For platform-specific builds or additional configuration options, please check the PHPacker documentation.
You can execute the binary directly:
./builds/build/mac/mac-armor on Linux:
./builds/build/linux/linux-x64or on Windows:
C:\application\path> builds\build\windows\windows-x64.exeThe binary is completely self-contained and can be distributed as a single file without any dependencies.
- Binary files are larger than PHAR archives due to the embedded PHP runtime
- Build process requires network access to download PHP binaries
- Some PHP extensions may not be available in the embedded runtime