import{_ as t,c as d,o as a,aj as i}from"./chunks/framework.C2AwuPrQ.js";const k=JSON.parse('{"title":"Migrating from v2","description":"","frontmatter":{},"headers":[],"relativePath":"en/guide/migrate-from-v2.md","filePath":"en/guide/migrate-from-v2.md"}'),s={name:"en/guide/migrate-from-v2.md"};function o(n,e,l,c,r,h){return a(),d("div",null,[...e[0]||(e[0]=[i(`

Migrating from v2

StaticPHP v3 is a ground-up rewrite. The core build workflow (download → build → combine) remains familiar, but several commands, options, and configuration fields have changed. This page covers everything you need to update before switching.

Scope

This guide only covers user-facing CLI commands, options, craft.yml fields, and env.ini variable names. Internal PHP APIs are not covered.

Documentation URL Change

The official documentation site has moved:

Update any bookmarks or internal links accordingly.

spc Binary Download URL Change

The nightly spc self-contained binary has moved to a new path:

URL
v2https://dl.static-php.dev/static-php-cli/spc-bin/nightly/
v3https://dl.static-php.dev/v3/spc-bin/nightly/

Update any CI scripts or bootstrap commands that download the spc binary directly. For example:

bash
# v2
curl -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-linux-x86_64

# v3
curl -o spc https://dl.static-php.dev/v3/spc-bin/nightly/spc-linux-x86_64

Removed Commands

v2 Commandv3 ReplacementNotes
del-downloadspc resetreset also accepts --with-pkgroot and --with-download for finer control
del-download --allspc reset --with-downloadRemoves the downloads cache directory

Removed Options

--with-added-patch / -P (build command)

This option allowed injecting external PHP patch scripts at specific build stages. It has been removed in v3.

There is no direct drop-in replacement. If you relied on this feature:

Future Plans

A single-file hook API for lightweight patches may be provided in a future release.

Windows-only: --with-sdk-binary-dir and --vs-ver

These options are no longer accepted on the command line. Instead, set the PHP_SDK_PATH environment variable to point to your PHP SDK binary tools directory. The Visual Studio version is now managed by the toolchain configuration.

Renamed / Deprecated Options

The following options have been renamed. The old names are accepted where noted, but you should update your scripts.

v2 Optionv3 OptionStatus
--prefer-pre-built--prefer-binary / -pOld name kept as a deprecated alias
--with-libs=<list>--with-packages=<list>
--with-suggested-libs / -L--with-suggestsOld -L / -E flags removed
--with-suggested-exts / -E--with-suggestsMerged into a single flag

Example

bash
# v2
spc build curl,gd --build-cli --with-libs="openssl" -L -E

# v3
spc build curl,gd --build-cli --with-packages="openssl" --with-suggests

Changed build Command Behaviour

The build command (alias: build:php) still works. However, v3 also provides dedicated single-target commands that do not require SAPI selection flags:

v2v3 Equivalent
spc build exts --build-clispc build:php-cli exts
spc build exts --build-fpmspc build:php-fpm exts
spc build exts --build-cgispc build:php-cgi exts
spc build exts --build-microspc build:php-micro exts
spc build exts --build-embedspc build:php-embed exts
spc build exts --build-frankenphpspc build:frankenphp exts

Use build:php when you need to build multiple SAPIs in one pass (the --build-* flags remain valid there).

Automatic Download in Build Commands

In v3, all build:* commands automatically download any missing dependencies before building. You no longer need to run spc download as a separate step:

bash
# v2 — two steps required
spc download --for-extensions=curl,gd
spc build curl,gd --build-cli

# v3 — one step is enough
spc build:php-cli curl,gd

To opt out of the automatic download (for example in CI where sources are pre-cached), pass --no-download:

bash
spc build:php-cli curl,gd --no-download

Changed download Command Options

v2v3Notes
--prefer-pre-built--prefer-binary / -pDeprecated alias kept
--with-libs--for-libsSeparate from packages
(no equivalent)--for-packagesUnified package filter
(no equivalent)--parallel / -PParallel downloads
(no equivalent)--retry / -RRetry on failure

Removed Dev Commands

These development utility commands have been removed or consolidated:

v2 Commandv3 Replacement
dev:extensions / list-extspc dev:info <package>
dev:ext-version / dev:ext-verspc dev:info <package>
dev:lib-version / dev:lib-verspc dev:info <package>
dev:php-version / dev:php-verspc dev:info php-src
dev:gen-ext-dep-docs + dev:gen-lib-dep-docsspc dev:gen-deps-data

Renamed Dev Commands

v2v3Notes
dev:sort-config / sort-configdev:lint-configOld alias still accepted

New Commands in v3

These commands are new in v3 with no v2 equivalent:

CommandDescription
spc resetClean buildroot/ and source/ directories
spc check-updateCheck for newer artifact versions
spc build:php-cliBuild CLI SAPI (no flags needed)
spc build:php-fpmBuild PHP-FPM (no flags needed)
spc build:php-cgiBuild PHP CGI (no flags needed)
spc build:php-microBuild phpmicro (no flags needed)
spc build:php-embedBuild embed SAPI (no flags needed)
spc build:frankenphpBuild FrankenPHP (no flags needed)
spc dev:shellInteractive shell with build environment
spc dev:is-installedCheck whether a package is installed
spc dev:dump-stagesDump all package build stages to JSON
spc dev:dump-capabilitiesDump buildable/installable capabilities
spc dev:infoShow configuration info for a package

craft.yml Changes

Removed: build-options.with-added-patch

The with-added-patch key inside build-options is no longer parsed and will be silently ignored. Remove it from your craft.yml:

yaml
# v2 — remove this block
build-options:
  with-added-patch:
    - my-patch.php

libspackages (both work)

The top-level libs field still works. The preferred v3 field name is packages, which is a superset covering libraries and other tool packages:

yaml
# v2
libs: nghttp2,liblz4

# v3 (preferred)
packages: nghttp2,liblz4

env.ini Variable Renames

If you customise config/env.ini or export environment variables in CI, update the following names:

v2 Variablev3 Variable
SPC_LINUX_DEFAULT_CCSPC_DEFAULT_CC
SPC_LINUX_DEFAULT_CXXSPC_DEFAULT_CXX
SPC_LINUX_DEFAULT_ARSPC_DEFAULT_AR
SPC_LINUX_DEFAULT_LDSPC_DEFAULT_LD
SPC_LIBCSPC_TARGET

SPC_TARGET uses a new format that encodes both architecture and libc in a single string, for example:

v2v3
SPC_LIBC=muslSPC_TARGET=x86_64-linux-musl
SPC_LIBC=gnuSPC_TARGET=x86_64-linux-gnu.2.17

New logging variables were also added (SPC_ENABLE_LOG_FILE, SPC_LOGS_DIR, SPC_PRESERVE_LOGS). Refer to Environment Variables for details.

`,59)])])}const g=t(s,[["render",o]]);export{k as __pageData,g as default};