Skip to content

Build and distribute standalone PHP CLI alongside FrankenPHP#57

Merged
munezaclovis merged 3 commits intofeat/build-static-php-binariesfrom
claude/build-static-php-FClJ6
Apr 14, 2026
Merged

Build and distribute standalone PHP CLI alongside FrankenPHP#57
munezaclovis merged 3 commits intofeat/build-static-php-binariesfrom
claude/build-static-php-FClJ6

Conversation

@munezaclovis
Copy link
Copy Markdown
Contributor

Summary

This PR adds support for building and distributing a standalone PHP CLI binary that shares the exact same extension set as the FrankenPHP binary. Previously, the PHP CLI was downloaded from static-php.dev, which could have different extensions. Now both binaries are built together and distributed from the same release.

Key Changes

  • Build Configuration: Added SPC_OPT_BUILD_ARGS: "--build-cli" to the build workflow to compile the standalone PHP CLI alongside FrankenPHP
  • Artifact Packaging: Added new workflow steps to package the compiled PHP CLI binary into a tarball (php-mac-{arch}-php{version}.tar.gz)
  • Release Management: Updated the release job to download and upload both FrankenPHP and PHP CLI artifacts
  • Installation Logic: Modified phpCLIURL() to download the PHP CLI from the same GitHub release as FrankenPHP instead of from static-php.dev, ensuring version consistency and identical extension sets
  • Documentation: Updated comments to reflect that both FrankenPHP and PHP CLI are now built and distributed together

Implementation Details

  • The PHP CLI is built using the same static-php-cli build process with the --build-cli flag
  • The binary is packaged as a gzipped tarball containing a single php executable
  • The download URL now uses the release tag and version to fetch from the custom build repository (prvious/pv)
  • Removed the previous logic that attempted to detect the full PHP version from the binary and map architecture/OS names, as the new approach uses the release tag directly

https://claude.ai/code/session_012F7YzeARQRFMj3SbKDRpic

claude and others added 3 commits April 13, 2026 19:57
Set SPC_OPT_BUILD_ARGS="--build-cli" so static-php-cli emits both
the frankenphp and standalone php binaries in one invocation. This
guarantees both share an identical extension set (previously the
CLI came from dl.static-php.dev with a different build).

The CI workflow now packages dist/static-php-cli/buildroot/bin/php
into php-mac-{arch}-php{version}.tar.gz and uploads it to the same
release as the frankenphp assets.

phpCLIURL is rewritten to resolve to our own release using the
existing platformName() helper, unifying naming with the frankenphp
asset. The full-version detect step (only used to build the old
static-php.dev URL) and the now-unused phpOSNames/phpArchNames maps
are removed.
Follow-ups from PR review:

- Gate the release job on refs/heads/main so feature-branch dispatches
  exercise the build matrix without publishing to the release.
- Assert every FrankenPHP binary has a matching PHP CLI tarball before
  upload (nullglob + count + per-pair existence) so partial builds can
  never produce an incomplete release.
- Remove DetectPHPVersion and ParseFrankenPHPPhpVersion; they lost
  their only caller when the PHP CLI moved to the unified release URL.
- Extract platformNameFor(goos, goarch) and add table tests for it,
  plus exact-format tests for phpCLIURL and frankenphpAssetName.
The actions/cache step restores dist/static-php-cli/downloads/, which
creates the parent dist/static-php-cli/ containing only downloads/.
build-static.sh's check for static-php-cli/src then fails, and its
fallback `git clone ... static-php-cli` aborts with exit 128 because
the directory already exists.

Pre-cloning the repo before the cache step ensures src/ is present,
so build-static.sh takes the `cd static-php-cli/ && git pull` branch
regardless of cache hit or miss.
@munezaclovis munezaclovis merged commit 3ec3400 into feat/build-static-php-binaries Apr 14, 2026
5 of 6 checks passed
munezaclovis added a commit that referenced this pull request Apr 14, 2026
The release workflow forwards FrankenPHP binaries from the previous
release to each new release, but the PHP CLI tarballs added in #57
were not part of that copy. Add php-* to the download pattern so
both binary sets propagate forward together.
@munezaclovis munezaclovis deleted the claude/build-static-php-FClJ6 branch April 22, 2026 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants