From 44857e85a12a5818170626126b0aa02d192dbc0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Sun, 25 Oct 2026 15:59:59 +0100 Subject: [PATCH] feat(static): allow external static-php-cli registries and spc binaries Third-party and private extensions can be added through a static-php-cli registry: document SPC_REGISTRIES and allow selecting the spc binary with SPC, since registry support requires a recent static-php-cli. --- build-static.sh | 5 ++++- docs/static.md | 13 +++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/build-static.sh b/build-static.sh index 5aa4a04c8c..6fd7eadb46 100755 --- a/build-static.sh +++ b/build-static.sh @@ -24,6 +24,9 @@ set -o pipefail # DEBUG_SYMBOLS is set (default: none) # - MIMALLOC: when set, use mimalloc as the allocator (default: none) # - OUTPUT_DIR: where to write the resulting binary (default: dist/) +# - SPC: spc binary, or bin/spc of a static-php-cli checkout, to use (default: the nightly) +# - SPC_REGISTRIES: comma-separated static-php-cli registries providing more +# extensions for PHP_EXTENSIONS (read by static-php-cli itself) # - RELEASE: [maintainer only] create a GitHub release if set to 1 (default: none) # # The libc to link against (Linux only) is selected with: @@ -110,7 +113,7 @@ if type "brew" >/dev/null 2>&1; then fi # Fetch the spc binary if we don't have it yet, falling back to source -spc="${DIST_DIR}/spc" +spc="${SPC:-${DIST_DIR}/spc}" if [ ! -x "${spc}" ]; then # the nightly endpoint occasionally answers 500, retry instead of failing the build if curl -fsSL --retry 5 -o "${spc}" "https://dl.static-php.dev/v3/spc-bin/nightly/spc-${spc_os}-${spc_arch}"; then diff --git a/docs/static.md b/docs/static.md index bf79e2888b..db444eb76e 100644 --- a/docs/static.md +++ b/docs/static.md @@ -80,6 +80,19 @@ docker run --rm -v "$PWD/output:/output" -e OUTPUT_DIR=/output -e SPC_LOGS_DIR=/ dunglas/frankenphp:static-builder-musl ``` +### Third-party and private extensions + +Extensions that static-php-cli doesn't know about, including private ones shipped as +prebuilt archives, can be provided by an [external static-php-cli registry](https://static-php.dev/en/develop/registry). +Point `SPC_REGISTRIES` to its declaration file and add the extension to `PHP_EXTENSIONS`: + +```console +SPC_REGISTRIES=/path/to/spc.registry.yml PHP_EXTENSIONS=opcache,my_extension ./build-static.sh +``` + +To use a static-php-cli version other than the nightly binary, for instance a checkout of its +source, set `SPC` to the `spc` binary or to the `bin/spc` script of the checkout. + ### Extra Caddy modules To add extra Caddy modules or pass other arguments to [xcaddy](https://github.com/caddyserver/xcaddy), use the `XCADDY_ARGS` variable: