<spanclass="line"><spanstyle="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> - </span><spanstyle="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">micro</span></span></code></pre></div><p>Not sure which extensions you need? Use the <ahref="./cli-generator.html">command generator</a> to produce a <code>craft.yml</code> automatically.</p><h3id="run-the-build"tabindex="-1">Run the Build <aclass="header-anchor"href="#run-the-build"aria-label="Permalink to “Run the Build”"></a></h3><divclass="language-bash"><buttontitle="Copy Code"class="copy"></button><spanclass="lang">bash</span><preclass="shiki shiki-themes github-light github-dark"style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;"tabindex="0"dir="ltr"><code><spanclass="line"><spanstyle="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">spc</span><spanstyle="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> craft</span></span></code></pre></div><p>The build pipeline runs in order: download dependencies → compile libraries → compile PHP. No interaction required.</p><p>To see more detail, pass <code>-v</code>, <code>-vv</code>, or <code>-vvv</code>:</p><divclass="language-bash"><buttontitle="Copy Code"class="copy"></button><spanclass="lang">bash</span><preclass="shiki shiki-themes github-light github-dark"style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;"tabindex="0"dir="ltr"><code><spanclass="line"><spanstyle="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">spc</span><spanstyle="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> craft</span><spanstyle="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -v</span></span></code></pre></div><h3id="inspect-the-output"tabindex="-1">Inspect the Output <aclass="header-anchor"href="#inspect-the-output"aria-label="Permalink to “Inspect the Output”"></a></h3><p>On success, binaries land in <code>buildroot/bin/</code>:</p><tabletabindex="0"><thead><tr><th>SAPI</th><th>Output path</th></tr></thead><tbody><tr><td>cli</td><td><code>buildroot/bin/php</code> (Windows: <code>buildroot/bin/php.exe</code>)</td></tr><tr><td>fpm</td><td><code>buildroot/bin/php-fpm</code></td></tr><tr><td>micro</td><td><code>buildroot/bin/micro.sfx</code></td></tr><tr><td>embed</td><td><code>buildroot/lib/libphp.a</code></td></tr><tr><td>frankenphp</td><td><code>buildroot/bin/frankenphp</code></td></tr></tbody></table><p>Give the CLI binary a quick smoke-test:</p><divclass="language-bash"><buttontitle="Copy Code"class="copy"></button><spanclass="lang">bash</span><preclass="shiki shiki-themes github-light github-dark"style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;"tabindex="0"dir="ltr"><code><spanclass="line"><spanstyle="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">./buildroot/bin/php</span><spanstyle="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -v</span></span>
<spanclass="line"><spanstyle="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">./buildroot/bin/php</span><spanstyle="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -m</span></span></code></pre></div><h2id="option-2-step-by-step-build"tabindex="-1">Option 2: Step-by-Step Build <aclass="header-anchor"href="#option-2-step-by-step-build"aria-label="Permalink to “Option 2: Step-by-Step Build”"></a></h2><p>This approach lets you run download and compile as separate steps — useful when you want to cache downloads in CI and reuse them across builds.</p><h3id="step-1-download-dependencies"tabindex="-1">Step 1: Download Dependencies <aclass="header-anchor"href="#step-1-download-dependencies"aria-label="Permalink to “Step 1: Download Dependencies”"></a></h3><p>In v3, you can skip this step entirely — running <code>build:php</code> directly will automatically download any missing artifacts.</p><p>If you want to pre-download ahead of time, or if you're working in a slow-network environment and want to separate the download phase, use the <code>download</code> command:</p><divclass="language-bash"><buttontitle="Copy Code"class="copy"></button><spanclass="lang">bash</span><preclass="shiki shiki-themes github-light github-dark"style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;"tabindex="0"dir="ltr"><code><spanclass="line"><spanstyle="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># Download only what the chosen extensions need (recommended)</span></span>
<spanclass="line"><spanstyle="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># Download by specific package names</span></span>
<spanclass="line"><spanstyle="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">spc</span><spanstyle="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> download</span><spanstyle="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"curl,openssl"</span><spanstyle="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --with-php=8.5</span></span></code></pre></div><p>Downloads are cached in <code>downloads/</code> and reused across builds automatically.</p><divclass="language-bash"><buttontitle="Copy Code"class="copy"></button><spanclass="lang">bash</span><preclass="shiki shiki-themes github-light github-dark"style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;"tabindex="0"dir="ltr"><code><spanclass="line"><spanstyle="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># Slow connection? Increase parallelism and retries</span></span>
<spanclass="line"><spanstyle="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># Use pre-built binaries where available — skips compiling those dependencies</span></span>
<spanclass="line"><spanstyle="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># Build multiple SAPIs in one go</span></span>
<spanclass="line"><spanstyle="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">spc</span><spanstyle="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> build:php</span><spanstyle="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"bcmath,phar,zlib,openssl,curl"</span><spanstyle="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --build-cli</span><spanstyle="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --build-micro</span></span></code></pre></div><h4id="common-build-options"tabindex="-1">Common Build Options <aclass="header-anchor"href="#common-build-options"aria-label="Permalink to “Common Build Options”"></a></h4><tabletabindex="0"><thead><tr><th>Option</th><th>Description</th></tr></thead><tbody><tr><td><code>--build-cli</code></td><td>Build the cli SAPI</td></tr><tr><td><code>--build-fpm</code></td><td>Build php-fpm (not available on Windows)</td></tr><tr><td><code>--build-micro</code></td><td>Build micro.sfx</td></tr><tr><td><code>--build-embed</code></td><td>Build the embed SAPI</td></tr><tr><td><code>--build-frankenphp</code></td><td>Build FrankenPHP</td></tr><tr><td><code>--enable-zts</code></td><td>Enable thread-safe (ZTS) mode</td></tr><tr><td><code>--no-strip</code></td><td>Keep debug symbols; do not strip the binary</td></tr><tr><td><code>-I key=value</code></td><td>Hard-compile an INI option into PHP</td></tr><tr><td><code>--with-upx-pack</code></td><td>Compress output with UPX (run <code>spc install-pkg upx</code> first)</td></tr></tbody></table><p>Example — baking in a larger memory limit and disabling the <code>system</code> function:</p><divclass="language-bash"><buttontitle="Copy Code"class="copy"></button><spanclass="lang">bash</span><preclass="shiki shiki-themes github-light github-dark"style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;"tabindex="0"dir="ltr"><code><spanclass="line"><spanstyle="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">spc</span><spanstyle="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> build:php</span><spanstyle="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"bcmath,pcntl,posix"</span><spanstyle="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --build-cli</span><spanstyle="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -I</span><spanstyle="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"memory_limit=4G"</span><spanstyle="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -I</span><spanstyle="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"disable_functions=system"</span></span></code></pre></div><h2id="packaging-a-micro-app"tabindex="-1">Packaging a micro App <aclass="header-anchor"href="#packaging-a-micro-app"aria-label="Permalink to “Packaging a micro App”"></a></h2><p>Once you have <code>micro.sfx</code>, use <code>micro:combine</code> to bundle your PHP code into a single self-contained executable:</p><divclass="language-bash"><buttontitle="Copy Code"class="copy"></button><spanclass="lang">bash</span><preclass="shiki shiki-themes github-light github-dark"style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;"tabindex="0"dir="ltr"><code><spanclass="line"><spanstyle="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">echo</span><spanstyle="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"<?php echo 'Hello, World!' . PHP_EOL;"</span><spanstyle="--shiki-light:#D73A49;--shiki-dark:#F97583;">></span><spanstyle="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> hello.php</span></span>
<spanclass="line"><spanstyle="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">./hello</span></span></code></pre></div><p>Works with <code>.phar</code> files too, and you can inject INI settings at packaging time:</p><divclass="language-bash"><buttontitle="Copy Code"class="copy"></button><spanclass="lang">bash</span><preclass="shiki shiki-themes github-light github-dark"style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;"tabindex="0"dir="ltr"><code><spanclass="line"><spanstyle="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># Bundle a phar</span></span>
<spanclass="line"><spanstyle="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># Inject INI from a file</span></span>
<spanclass="line"><spanstyle="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">spc</span><spanstyle="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> micro:combine</span><spanstyle="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> your-app.phar</span><spanstyle="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --output=your-app</span><spanstyle="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -N</span><spanstyle="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /path/to/custom.ini</span></span></code></pre></div><h2id="debugging-and-rebuilding"tabindex="-1">Debugging and Rebuilding <aclass="header-anchor"href="#debugging-and-rebuilding"aria-label="Permalink to “Debugging and Rebuilding”"></a></h2><p>If a build fails or you want to trace what's happening, use <code>-v</code> / <code>-vv</code> / <code>-vvv</code>:</p><divclass="language-bash"><buttontitle="Copy Code"class="copy"></button><spanclass="lang">bash</span><preclass="shiki shiki-themes github-light github-dark"style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;"tabindex="0"dir="ltr"><code><spanclass="line"><spanstyle="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">spc</span><spanstyle="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> build:php</span><spanstyle="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"bcmath,openssl"</span><spanstyle="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --build-cli</span><spanstyle="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -vv</span></span></code></pre></div><ul><li><code>-v</code> shows <code>INFO</code>-level logs: which modules are running and what build commands are being executed.</li><li><code>-vv</code> shows <code>DEBUG</code>-level logs: all internal debug output from StaticPHP.</li><li><code>-vvv</code> shows <code>DEBUG</code>-level logs and also pipes the stdout of every shell command directly to your terminal.</li></ul><p>To wipe compiled artifacts and start fresh without re-downloading, run <code>reset</code>:</p><divclass="language-bash"><buttontitle="Copy Code"class="copy"></button><spanclass="lang">bash</span><preclass="shiki shiki-themes github-light github-dark"style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;"tabindex="0"dir="ltr"><code><spanclass="line"><spanstyle="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">spc</span><spanstyle="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> reset</span></span>
<spanclass="line"><spanstyle="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># Then rebuild</span></span>