PHPackages                             crazywhalecc/static-php-cli - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. crazywhalecc/static-php-cli

ActiveLibrary[CLI &amp; Console](/categories/cli)

crazywhalecc/static-php-cli
===========================

Build single static PHP binary, with PHP project together, with popular extensions included.

2.8.5(2mo ago)1.9k17.6k↓11.6%395[29 issues](https://github.com/crazywhalecc/static-php-cli/issues)[7 PRs](https://github.com/crazywhalecc/static-php-cli/pulls)MITPHPPHP &gt;= 8.3

Since Apr 23Pushed 5d ago21 watchersCompare

[ Source](https://github.com/crazywhalecc/static-php-cli)[ Packagist](https://packagist.org/packages/crazywhalecc/static-php-cli)[ Fund](https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md)[ RSS](/packages/crazywhalecc-static-php-cli/feed)WikiDiscussions v3 Synced 2d ago

READMEChangelog (10)Dependencies (33)Versions (109)Used By (0)

StaticPHP
=========

[](#staticphp)

[![Chinese readme](https://camo.githubusercontent.com/9737edd7526c0e955f0d434c401e671c86cd120a2b06b8c4b50b1f7b11a917f5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f524541444d452d2545342542382541442545362539362538372532302546302539462538372541382546302539462538372542332d6d6f63636173696e3f7374796c653d666c61742d737175617265)](README-zh.md)[![English readme](https://camo.githubusercontent.com/5455baad74f1690f737f9d248d450996345500c939f7b91a4e5bc7ea02dfc5ab/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f524541444d452d456e676c6973682532302546302539462538372541432546302539462538372541372d6d6f63636173696e3f7374796c653d666c61742d737175617265)](README.md)[![Releases](https://camo.githubusercontent.com/bb3d7ef861a2b15147490ec2e2a18a4ae0190d8dcec7f21e26b5db195c0a48be/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6372617a797768616c6563632f7374617469632d7068702d636c693f696e636c7564655f70726572656c6561736573266c6162656c3d52656c65617365267374796c653d666c61742d737175617265)](https://github.com/crazywhalecc/static-php-cli/releases)[![CI](https://camo.githubusercontent.com/043217146098538ce41ff69c446a57348fa6d8fc669ed58b56f74577573973be/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6372617a797768616c6563632f7374617469632d7068702d636c692f74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d4275696c6425323054657374267374796c653d666c61742d737175617265)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/tests.yml)[![License](https://camo.githubusercontent.com/a7e65aee57b11d28e4caff8b945729a66be0bb663f7f93bd24c5aa65699f148e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](https://github.com/crazywhalecc/static-php-cli/blob/main/LICENSE)[![Discord](https://camo.githubusercontent.com/b66a9160663a41669d97df0c71c1d830876fa3e43a579f4456c519eb5ad08c39/68747470733a2f2f696d672e736869656c64732e696f2f646973636f72642f6e72535262704d4a3f6c6162656c3d446973636f7264266c6f676f3d646973636f7264267374796c653d666c61742d737175617265)](https://discord.gg/xf6Rd4pEAk)

**StaticPHP** is a powerful tool designed for building portable executables including PHP, extensions, and more.

Important

We are preparing to release **v3**, which will include a project rename from **static-php-cli** to **StaticPHP**. And this branch is for v3. For v2, please check the [v2 branch](https://github.com/crazywhalecc/static-php-cli/tree/main). Please update your references and stay tuned for the official release.

Features
--------

[](#features)

- 🐘 Support multiple PHP versions - PHP 8.1, 8.2, 8.3, 8.4, 8.5
- 👜 Build single-file PHP executable with zero dependencies
- 🍔 Build **[phpmicro](https://github.com/static-php/phpmicro)** self-extracting executables (combines PHP binary and source code into one file)
- 💊 Automatic build environment checker with auto-fix capabilities
- ⚡ `Linux`, `macOS`, `Windows` support
- 🔧 Easy to extend with vendor mode and custom registries
- 📚 Intelligent dependency management
- 📦 Self-contained `spc` executable for easy self-installation
- 🔥 Support 100+ popular [PHP extensions](https://static-php.dev/en/guide/extensions.html)
- 💾 UPX compression support (reduces binary size by 30-50%)

**Single-file standalone php-cli:**

[![out1](https://private-user-images.githubusercontent.com/20330940/295232925-01a2e60f-13b0-4242-a645-f7afa4936396.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3ODI4OTYwMjksIm5iZiI6MTc4Mjg5NTcyOSwicGF0aCI6Ii8yMDMzMDk0MC8yOTUyMzI5MjUtMDFhMmU2MGYtMTNiMC00MjQyLWE2NDUtZjdhZmE0OTM2Mzk2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjA3MDElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwNzAxVDA4NDg0OVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTgwMDVlZGRkM2EzNjA4MGQyOGNkYjc4Y2YzNjUzZDdiNjUyZjIxYmJjMWQyYmZlN2U5YTNkZWU4NDljY2I0NDkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JnJlc3BvbnNlLWNvbnRlbnQtdHlwZT1pbWFnZSUyRnBuZyJ9.MSRD0ztP8ltV8YJ1wJc-117PL8tWiWCqkqxU6LLTckQ)](https://private-user-images.githubusercontent.com/20330940/295232925-01a2e60f-13b0-4242-a645-f7afa4936396.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3ODI4OTYwMjksIm5iZiI6MTc4Mjg5NTcyOSwicGF0aCI6Ii8yMDMzMDk0MC8yOTUyMzI5MjUtMDFhMmU2MGYtMTNiMC00MjQyLWE2NDUtZjdhZmE0OTM2Mzk2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjA3MDElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwNzAxVDA4NDg0OVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTgwMDVlZGRkM2EzNjA4MGQyOGNkYjc4Y2YzNjUzZDdiNjUyZjIxYmJjMWQyYmZlN2U5YTNkZWU4NDljY2I0NDkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JnJlc3BvbnNlLWNvbnRlbnQtdHlwZT1pbWFnZSUyRnBuZyJ9.MSRD0ztP8ltV8YJ1wJc-117PL8tWiWCqkqxU6LLTckQ)**Combine PHP code with PHP interpreter using phpmicro:**

[![out2](https://private-user-images.githubusercontent.com/20330940/295389383-46b7128d-fb72-4169-957e-48564c3ff3e2.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3ODI4OTYwMjksIm5iZiI6MTc4Mjg5NTcyOSwicGF0aCI6Ii8yMDMzMDk0MC8yOTUzODkzODMtNDZiNzEyOGQtZmI3Mi00MTY5LTk1N2UtNDg1NjRjM2ZmM2UyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNj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ZSUyRnBuZyJ9.vq3UtZAisXAO5t97sGvjMAkflyCMmZUnDYLnXC5wTaA)Quickstart
----------

[](#quickstart)

### 1. Download spc binary

[](#1-download-spc-binary)

```
# For Linux x86_64
curl -fsSL -o spc https://dl.static-php.dev/v3/spc-bin/nightly/spc-linux-x86_64
# For Linux aarch64
curl -fsSL -o spc https://dl.static-php.dev/v3/spc-bin/nightly/spc-linux-aarch64
# macOS x86_64 (Intel)
curl -fsSL -o spc https://dl.static-php.dev/v3/spc-bin/nightly/spc-macos-x86_64
# macOS aarch64 (Apple)
curl -fsSL -o spc https://dl.static-php.dev/v3/spc-bin/nightly/spc-macos-aarch64
# Windows (x86_64, win10 build 17063 or later, please install VS2022 first)
curl.exe -fsSL -o spc.exe https://dl.static-php.dev/v3/spc-bin/nightly/spc-windows-x64.exe
```

For macOS and Linux, add execute permission first:

```
chmod +x ./spc
```

### 2. Build Static PHP

[](#2-build-static-php)

First, create a `craft.yml` file and specify which extensions you want to include from [extension list](https://static-php.dev/en/guide/extensions.html) or [command generator](https://static-php.dev/en/guide/cli-generator.html):

```
# PHP version support: 8.1, 8.2, 8.3, 8.4, 8.5
php-version: 8.5
# Put your extension list here
extensions: "apcu,bcmath,calendar,ctype,curl,dba,dom,exif,fileinfo,filter,gd,iconv,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,readline,redis,session,simplexml,sockets,sodium,sqlite3,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib"
sapi:
  - cli
  - micro
download-options:
  parallel: 10
```

Run command:

```
./spc craft

# Output full console log
./spc craft -vvv
```

### 3. Static PHP usage

[](#3-static-php-usage)

Now you can copy binaries built by StaticPHP to another machine and run with no dependencies:

```
# php-cli
buildroot/bin/php -v

# phpmicro
echo '
