Skip to content

StaticPHP v3#980

Open
crazywhalecc wants to merge 717 commits intov3from
v3-dev
Open

StaticPHP v3#980
crazywhalecc wants to merge 717 commits intov3from
v3-dev

Conversation

@crazywhalecc
Copy link
Copy Markdown
Owner

@crazywhalecc crazywhalecc commented Nov 30, 2025

Important notes

STATUS: dev -> alpha -> beta -> rc -> stable

Contribution notes:

  • Before we released the first alpha version, any changes should be merged into v3-dev, not v3.
  • After we released the first alpha version, any changes should be merged into v3 and we will deprecate v3-dev branch.
  • The structure of StaticPHP v3 may be changed before beta version.
  • Publishing new RFC is welcome.

RFCs

Progress of refactoring

bin/ refactoring

  • bin/spc for v3
  • bin/spc-alpine-docker
  • bin/spc-gnu-docker
  • bin/docker-entrypoint.sh
  • bin/setup-runtime

v3 new modules

  • Registry module loading for all configs and packages (StaticPHP v3 #980)
  • Vendor mode support
    • Separate a dedicated bootstrap file for initialization (StaticPHP v3 #980) (src/bootstrap.php)
    • Add init-registry command for vendor user

Commands refactoring

  • ConsoleApplication dynamic generating commands for target type packages (StaticPHP v3 #980)

  • Custom commands in external registry (StaticPHP v3 #980)

  • DownloadCommand

  • BaseCommand

  • BuildLibsCommand

  • BuildPHPCommand -> BuildTargetCommand with php package

    • Options
      • --with-libs: Keep for compatibility, add --with-packages option (StaticPHP v3 #980)
      • --build-shared
      • --build-all: Special parsing in v3 (StaticPHP v3 #980)
      • --no-strip, --disable-opcache-jit, --build-{sapi}, --with-config-file-path, --with-config-file-scan-dir, --with-hardcoded-ini, --with-micro-fake-cli, --with-added-patch (-P), --without-micro-ext-test, --with-upx-pack, --with-micro-logo, --enable-micro-win32, --with-frankenphp-app has been moved to php package definition (StaticPHP v3 #980)
      • Implementation status
        • no-strip
        • disable-opcache-jit
        • with-config-file-path
        • with-config-file-scan-dir
        • with-hardcoded-ini
        • with-micro-fake-cli
        • with-addeed-patch
        • without-micro-ext-test
        • with-upx-pack
        • with-micro-logo
        • enable-micro-win32
        • with-frankenphp-app
        • build-shared
        • with-packages (with-libs)
        • build-all
        • build-{sapi} except build-frankenphp (StaticPHP v3 #980)
        • build-frankenphp
        • with-suggests (with-suggested-libs, with-suggested-exts)
        • no-download (StaticPHP v3 #980)
        • Download options in build command (StaticPHP v3 #980)
        • with-clean
    • Build information printing: refactored to attribute #[StaticPHP\Attribute\Package\Info] (StaticPHP v3 #980)
    • Bind build extra info to ExceptionHandler
    • Validate packages before building and after extracting (StaticPHP v3 #980)
    • Patch static-php-cli version to PHP has been moved to php package build stage before (StaticPHP v3 #980)
    • Display build PHP result in terminal
    • Export licenses and build extensions and lib info after building
  • CraftCommand

  • DeleteDownloadCommand

  • DoctorCommand (StaticPHP v3 #980) (Just command, not Doctor items)

  • DumpExtensionsCommand

  • DumpLicenseCommand

  • ExtractCommand (Just command, not Extractor)

  • InstallPkgCommand ->InstallPackageCommand

    • PackageInstaller calling
    • Options
      • skip-extract
  • MicroCombineCommand

  • SPCConfigCommand

    • SPCConfigUtil calling
    • Options
  • SwitchPhpVersionCommand

  • Dev commands

    • AllExtCommand
    • EnvCommand
    • ExtVerCommand
    • GenerateExtDepDocsCommand
    • GenerateExtDocCommand
    • GenerateLibDepDocsCommand
    • LibVerCommand
    • PackLibCommand
    • PhpVerCommand
    • SortConfigCommand

Doctor module

  • Core framework refactored (StaticPHP v3 #980)
    • Doctor main class
    • DoctorLoader for loading check items
    • CheckResult for storing check results
    • Attribute-based check system: #[CheckItem], #[OptionalCheck], #[FixItem]
  • Doctor check items
    • OSCheck (migrated from v2's OSCheckList)
    • Re2cVersionCheck
    • PkgConfigCheck
    • MacOSToolCheck (migrated from v2's MacOSToolCheckList)
    • LinuxMuslCheck
    • LinuxToolCheck (v2 has LinuxToolCheckList)
    • BSDToolCheck (v2 has BSDToolCheckList)
    • WindowsToolCheck (v2 has WindowsToolCheckList)
    • ZigCheck (v2 has ZigCheck)

Legacy modules (v2 only - SPC namespace)

These modules exist in v2 but are refactored/merged into new v3 modules:

  • store/ - Deprecated and refactored
    • Downloader → StaticPHP\Artifact\ArtifactDownloader
    • LockFile → StaticPHP\Artifact\ArtifactCache
    • CurlHook → Merged into StaticPHP\Artifact\ArtifactDownloader
    • FileSystem → StaticPHP\Util\FileSystem
    • DirDiff → StaticPHP\Util\DirDiff
    • SourcePatcher → StaticPHP\Util\SourcePatcher (partial)
    • PackageManager, SourceManager → Removed (functionality in new Package/Artifact systems)
    • pkg/ → Migrated to src/Package/
    • source/ → Migrated to Artifact system

@crazywhalecc crazywhalecc added the mixed PR This PR contains multiple updates label Nov 30, 2025
@crazywhalecc crazywhalecc self-assigned this Dec 4, 2025
@crazywhalecc
Copy link
Copy Markdown
Owner Author

crazywhalecc commented Dec 11, 2025

We should chat about what features we no longer want to support and what we want to rework.

@henderkes There's no urgent things. Just when you return from your vacation, and if you have time, it would be best we could discuss what modifications are still needed for the current framework of v3. Please feel free to contact me if you'd like.

Currently I've finished the major part of framework according to RFC, but I haven't ported most of the implementation yet, mainly to prevent major changes to the framework structure from requiring massive modifications.

And for anyone: If you have any feedback on the framework design, please let me know.

@henderkes
Copy link
Copy Markdown
Collaborator

I haven't had much of a look yet and the changelist is quite massive, so it might be a good idea to chat about it one evening after I had a rough glance. I'll give everything (especially vendor mode) a play and rewrite the static-php/packages properly on top of the new branch.

Might have to add versioned packages to it first though, because that's the part still holding up apk and proper apt support.

@crazywhalecc
Copy link
Copy Markdown
Owner Author

crazywhalecc commented Dec 11, 2025

For a quick reference for command mode, in the current branch, the available commands:

  • bin/spc doctor on Windows, macOS, Linux (linux is not fully tested)
  • bin/spc build:libs libedit on *nix
  • bin/spc build:php-cli readline on *nix
  • bin/spc build bcmath --build-cli --debug (--build-XXX and --debug has been marked as deprecated)
  • bin/spc build:libs onig on Windows
  • bin/spc download {some packages}
  • bin/spc download --for-extensions={some extensions}
  • bin/spc extract {some package}
  • bin/spc install-pkg {some package}
  • bin/spc spc-config {some extensions} (still using extension as argument)

The remaining commands and some of the option implementations may not have been tested.

@crazywhalecc
Copy link
Copy Markdown
Owner Author

Might have to add versioned packages to it first though

You mean the dependencies' version from artifacts?

@henderkes
Copy link
Copy Markdown
Collaborator

Might have to add versioned packages to it first though

You mean the dependencies' version from artifacts?

No, I mean versioned .deb packages like php-zts8.3-... Nothing on the spc side.

bin/spc build bcmath --build-cli --debug (--build-XXX and --debug has been marked as deprecated)

Why is --build-cli deprecated? What would be the new way to build multiple SAPIs at once?

@crazywhalecc
Copy link
Copy Markdown
Owner Author

crazywhalecc commented Dec 12, 2025

Why is --build-cli deprecated? What would be the new way to build multiple SAPIs at once?

I'm thinking of something like sapis arguments for build:php cli,fpm {extensions} command, not original build --build-XXX command. But it needs to separate build and build:php command, it will break compatibility.

I haven't decided any changes yet, but anyway we should current deprecate build command behavior. It should be building pacakge, not building php with extensions.

@crazywhalecc crazywhalecc added the RFC Request for comments label Feb 6, 2026
@crazywhalecc crazywhalecc requested a review from Copilot April 13, 2026 00:15
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR moves StaticPHP v3 toward the alpha stage by introducing a large set of v3 package/registry definitions, adding many new library/extension build recipes, and updating tooling/config (Composer, PHPStan, docs, CI) to match the new module/registry structure.

Changes:

  • Added many new Package\Library, Package\Extension, and Package\Artifact classes to support building additional libraries/extensions across Unix/Windows targets.
  • Introduced spc.registry.yml and extensive new YAML package definitions under config/pkg/** and config/artifact/**.
  • Updated dev tooling and docs (Composer/PHPStan/CaptainHook, guides, CI workflows) to reflect v3 structure and new shared-extension build support.

Reviewed changes

Copilot reviewed 292 out of 967 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/Package/Library/net_snmp.php Adds net-snmp library build/patch steps for Unix targets.
src/Package/Library/mpir.php Adds Windows build steps and VS detection for mpir.
src/Package/Library/mimalloc.php Adds Unix CMake build for mimalloc with musl handling.
src/Package/Library/libzip.php Adds CMake build for libzip (Unix/Windows) and pkg-config patching.
src/Package/Library/libyaml.php Adds Unix autoconf + Windows CMake build with Windows-only pre-patch.
src/Package/Library/libuv.php Adds CMake build for libuv (Unix/Windows) with pkg-config patching on Unix.
src/Package/Library/libuuid.php Adds Unix build for libuuid and writes a generated uuid.pc.
src/Package/Library/liburing.php Adds Linux build for liburing with musl-specific patching and libc logic.
src/Package/Library/libunistring.php Adds Unix autoconf build for libunistring and la patching.
src/Package/Library/libtiff.php Adds Unix build for libtiff with configure-file patches and optional deps.
src/Package/Library/libssh2.php Adds CMake build for libssh2 (Unix/Windows) with optional zlib on Unix.
src/Package/Library/librdkafka.php Adds librdkafka patching + Unix CMake build with optional deps.
src/Package/Library/librabbitmq.php Adds CMake build for librabbitmq and Windows renaming of lib output.
src/Package/Library/libpng.php Adds Unix autoconf build and Windows CMake build with post-build lib rename.
src/Package/Library/libmpdec.php Adds Unix autoconf build and a Windows NMake build with static lib discovery.
src/Package/Library/libmemcached.php Adds Unix CMake build for libmemcached on Linux/Darwin.
src/Package/Library/libmaxminddb.php Adds CMake build for libmaxminddb (Unix/Windows) with Windows lib name fixup.
src/Package/Library/liblz4.php Adds patches and build steps for liblz4 across Unix/Windows.
src/Package/Library/libjxl.php Adds Unix CMake build for libjxl with ZigToolchain AVX512 handling.
src/Package/Library/libjpeg.php Adds CMake build for libjpeg-turbo (Unix/Windows) + pkg-config patching/renames.
src/Package/Library/libiconv_win.php Adds Windows build steps and VS detection for libiconv-win.
src/Package/Library/libiconv.php Adds Unix autoconf build for libiconv with libcharset install step.
src/Package/Library/libheif.php Adds CMake patching/build for libheif and pkg-config patching.
src/Package/Library/libffi_win.php Adds Windows build steps and VS detection for libffi-win with header patch.
src/Package/Library/libffi.php Adds Unix autoconf build for libffi with Linux lib64->lib fixup and Darwin host/target args.
src/Package/Library/libedit.php Adds patching and Unix autoconf build for libedit with pkg-config patching.
src/Package/Library/libde265.php Adds Unix CMake build for libde265 and pkg-config patching.
src/Package/Library/libcares.php Adds Apple header patch + Unix autoconf build for c-ares with pkg-config patching.
src/Package/Library/libavif.php Adds Windows-source patch + CMake build for libavif across platforms.
src/Package/Library/libargon2.php Adds Linux Makefile patch + Unix build/install steps and cleanup.
src/Package/Library/libaom.php Adds CMake build for libaom (Unix/Windows), with Zig-specific env tweak.
src/Package/Library/libacl.php Adds a hook to patch PHP’s Makefile and builds libacl on Unix.
src/Package/Library/lerc.php Adds Unix CMake build for lerc.
src/Package/Library/ldap.php Adds configure-time patching and Unix build for OpenLDAP with pkg-config adjustments.
src/Package/Library/krb5.php Adds Unix autoconf build for krb5 with dependency-derived LIBS and pkg-config patching.
src/Package/Library/jbig.php Adds patching + Unix build steps for jbigkit.
src/Package/Library/idn2.php Adds Unix build for libidn2 with optional dependencies and pkg-config/la patching.
src/Package/Library/gmssl.php Adds CMake build for GmSSL, including Windows-specific generator/config.
src/Package/Library/gmp.php Adds Unix autoconf build for gmp with CFLAGS tweak and pkg-config patching.
src/Package/Library/gettext_win.php Adds Windows build steps and VS detection + vcxproj runtime library patching.
src/Package/Library/gettext.php Adds Unix build for gettext with optional deps and ZTS-specific threading flags.
src/Package/Library/freetype.php Adds Unix/Windows CMake build for freetype with CMake 4 compat handling.
src/Package/Library/fastlz.php Adds small Unix build recipe for fastlz with explicit tool invocation.
src/Package/Library/bzip2.php Adds patch + Unix/Windows build steps for bzip2.
src/Package/Library/attr.php Adds Unix build for attr with autogen steps and pkg-config patching.
src/Package/Extension/zlib.php Adds custom PHP configure arg logic for zlib across Unix.
src/Package/Extension/zip.php Adds custom PHP configure arg logic for zip across Unix.
src/Package/Extension/yaml.php Adds Windows-only patch for yaml’s config.w32 static libyaml linking.
src/Package/Extension/yac.php Adds source patching hooks for yac before buildconf.
src/Package/Extension/xz.php Adds Windows buildconf patch for xz extension config.w32.
src/Package/Extension/xlswriter.php Adds configure args and Unix/Windows build patches for xlswriter.
src/Package/Extension/xhprof.php Adds buildconf hook for xhprof to symlink into PHP tree and patch config.m4.
src/Package/Extension/uv.php Adds validation and Windows/unix build patches for ext-uv.
src/Package/Extension/trader.php Adds buildconf patch for trader config.m4 macro naming.
src/Package/Extension/swow.php Adds configure arg logic and buildconf symlink/patching for swow.
src/Package/Extension/sqlsrv.php Adds Windows flags removal patches for sqlsrv config.w32 and Makefile.
src/Package/Extension/spx.php Adds buildconf/configure patches to fix static/shared build issues for spx.
src/Package/Extension/snmp.php Adds buildconf patching for snmp extension and injects pkg-config libs.
src/Package/Extension/redis.php Adds configure arg logic for redis across Unix/Windows with optional deps.
src/Package/Extension/readline.php Adds musl static readline patching around make stage.
src/Package/Extension/rdkafka.php Adds config.m4 patching, source patching, and configure arg logic for rdkafka.
src/Package/Extension/rar.php Adds macOS-specific compiler flag patch for rar extension.
src/Package/Extension/protobuf.php Adds validation to prevent unsupported PHP versions and grpc conflict.
src/Package/Extension/phar.php Adds micro-SAPI patching and shared-build config.m4 swapping for phar.
src/Package/Extension/pgsql.php Adds PHP 8.4+ pgsql configure env overrides and shared build env tweaks.
src/Package/Extension/pdo_sqlsrv.php Adds Windows SDL flag removal and PHP 8.5+ source layout adjustment.
src/Package/Extension/pdo_sqlite.php Adds configure patch for sqlite3_column_table_name.
src/Package/Extension/pdo_odbc.php Adds buildconf patch for iconv linkage and configure args for ODBC.
src/Package/Extension/password_argon2.php Adds cli smoke test and configure arg selection depending on PHP/openssl.
src/Package/Extension/parallel.php Adds ZTS validation and config.m4 patch to remove hardcoded PHP_VERSION.
src/Package/Extension/opentelemetry.php Adds Unix make-stage env CFLAGS tweak.
src/Package/Extension/openssl.php Adds PHP 8.0 + OpenSSL3 workaround and configure arg logic for argon2.
src/Package/Extension/mongodb.php Adds Windows buildconf patch and configure args for mongodb with optional deps.
src/Package/Extension/memcached.php Adds configure args for memcached with libmemcached/fastlz integration.
src/Package/Extension/memcache.php Adds buildconf/configure patches to support static/shared builds.
src/Package/Extension/mbstring.php Adds configure args for mbstring and toggling mbregex.
src/Package/Extension/mbregex.php Adds a “no-op” custom configure arg stub for mbregex.
src/Package/Extension/maxminddb.php Adds buildconf patch to flatten new maxminddb source layout.
src/Package/Extension/intl.php Adds Windows buildconf patch to use PHP_INTL_SHARED rather than hardcoded true.
src/Package/Extension/imap.php Adds ZTS restriction validation, buildconf patches, and configure args for imap.
src/Package/Extension/imagick.php Adds configure args and disables OMP function probe.
src/Package/Extension/glfw.php Adds patching to stage ext-glfw into PHP tree and inject Linux X11 flags.
src/Package/Extension/gd.php Adds configure args based on detected library packages.
src/Package/Extension/ffi.php Adds CentOS 7 specific patch application hook for FFI.
src/Package/Extension/excimer.php Adds shared env adjustment to remove -lphp from LIBS.
src/Package/Extension/event.php Adds configure args for event and macOS-specific php_config.h patch.
src/Package/Extension/ev.php Adds Windows buildconf patch to respect PHP_EV_SHARED.
src/Package/Extension/dio.php Adds buildconf patch to copy missing header for dio.
src/Package/Extension/decimal.php Adds symbol rename and Windows dep ordering fix for decimal extension.
src/Package/Extension/amqp.php Adds Windows header patching to remove #warning directives.
src/Package/Artifact/pkg_config.php Adds pkg-config source patch hook for GCC 15 compatibility.
src/Package/Artifact/openssl.php Adds post-extract patch for OpenSSL 1.1 on Darwin.
src/Package/Artifact/libaom.php Adds musl-specific libaom patch hook.
src/Package/Artifact/imagick.php Adds imagick patch hook for PHP 8.4 compatibility based on ext version.
src/Package/Artifact/gmssl.php Adds gmssl source patch to rename OPENSSL_* functions.
src/Package/Artifact/bzip2.php Adds bzip2 Makefile -fPIC patch hook.
src/Package/Artifact/attr.php Adds attr patch hook (musl/macOS) for gethostname declaration.
spc.registry.yml Introduces core registry config and PSR-4 mappings for v3 packages/artifacts/commands.
phpstan.neon Updates PHPStan config (PHP 8.4 target, ignores, exclude paths).
docs/zh/guide/manual-build.md Documents new shared-extension patch points.
docs/zh/guide/action-build.md Updates Action build docs to include shared extensions and FrankenPHP notes.
docs/en/guide/manual-build.md Fixes table formatting and documents new shared-extension patch points.
docs/en/guide/action-build.md Updates Action build docs to include shared extensions and FrankenPHP notes.
config/pre-built.json Removes old pre-built configuration JSON.
config/pkg/target/zig.yml Adds zig target package definition.
config/pkg/target/vswhere.yml Adds vswhere target package definition for Windows.
config/pkg/target/upx.yml Adds upx target package definition.
config/pkg/target/strawberry-perl.yml Adds Strawberry Perl target package definition for Windows.
config/pkg/target/rust.yml Adds rust target package definition.
config/pkg/target/re2c.yml Adds re2c target package definition (source + static bin).
config/pkg/target/protoc.yml Adds protoc target package definition.
config/pkg/target/pkg-config.yml Adds pkg-config target definition with hosted binaries.
config/pkg/target/php.yml Adds PHP target and virtual-target definitions, including php-micro.
config/pkg/target/php-sdk-binary-tools.yml Adds PHP SDK tools target package for Windows.
config/pkg/target/nasm.yml Adds nasm target package for Windows.
config/pkg/target/musl-toolchain.yml Adds musl toolchain target package definitions.
config/pkg/target/jom.yml Adds jom target package for Windows.
config/pkg/target/htop.yml Adds htop target definition (source + ncursesw dep).
config/pkg/target/go-xcaddy.yml Adds Go/xcaddy tool target definition.
config/pkg/target/go-win.yml Adds Go tool target definition for Windows.
config/pkg/target/frankenphp.yml Adds frankenphp target definition including OS-specific deps and bins.
config/pkg/target/curl.yml Adds curl target package definition and dependency graph.
config/pkg/lib/*.yml Adds many new library package definitions (sources, deps, headers, static libs, licensing).
config/pkg/ext/*.yml Adds many php-extension package definitions (sources, deps, arg types, OS constraints).
config/artifact/php-src.yml Adds php-src artifact definition with licensing and mirror info.
config/artifact/ncurses.yml Adds ncurses artifact definition using hosted binary and filelist source.
config/artifact/musl-wrapper.yml Adds musl-wrapper artifact source definition.
config/artifact/glfw.yml Adds glfw artifact definition for php-glfw source.
composer.json Updates required PHP version to 8.4, updates dependencies/dev-tooling, and changes autoload mappings.
captainhook.json Updates pre-push/pre-commit hook commands and adds config linting hook.
README.md Renames project to StaticPHP and updates messaging/wording.
README-zh.md Renames project to StaticPHP and updates wording.
README-en.md Removes old stub file (English README moved).
.php-cs-fixer.php Updates fixer finder paths to new tests namespace/directory.
.github/workflows/tests.yml Expands PR workflow branches to include v3.
.github/workflows/build-windows-x86_64.yml Adds with-suggested-libs workflow input.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

crazywhalecc and others added 4 commits April 13, 2026 08:21
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@henderkes
Copy link
Copy Markdown
Collaborator

For gnu docker, do you think we should update to alma 8 or drop it entirely and rely on zig?

@crazywhalecc
Copy link
Copy Markdown
Owner Author

crazywhalecc commented Apr 13, 2026

For gnu docker, do you think we should update to alma 8 or drop it entirely and rely on zig?

To be honest, if conditions permit, I will try to avoid using Docker anyway. But whether to keep gnu-docker depends on whether we absolutely have to use it to build anything. I prefer to avoid using Docker, especially when Zig can almost completely cover it.

The other day, while using Docker on my Mac, engine crashed and a factory reset button clicked, which has no double-checking, caused me to lose all the data in all my Docker volumes, containers, images at all.

Some of the software I need for my work is developed in Java web, but they are deployed using Docker on ordinary people's computers. Solving Docker problems takes up almost all of their customer service time.

@henderkes
Copy link
Copy Markdown
Collaborator

We could drop Docker entirely. Zig also supports building musl-linked binaries, both static and dynamic. It's just that it produces slow binaries on php < 8.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mixed PR This PR contains multiple updates RFC Request for comments

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants