Skip to main content

static-php-build

Bake the PHP extensions you need into a portable host binary, once, at packaging time.

Produce a host PHP binary loading a required extension set by driving static-php-cli (spc).

Install

pip install static-php-build

A build-time / development dependency, not a runtime dependency of a consumer's end users. spc compilers are bundled per host platform; hosts without a bundled spc supply one via --spc PATH.

Usage

# Build a host PHP binary loading the given extensions, write it to ./php
static-php-build --extensions tokenizer,mbstring --out ./php

# Read the required set from the consumer's requirement declaration instead
static-php-build --manifest your_lib:REQUIREMENTS --out ./php

# Pin the PHP version, and forward unmodeled spc options after the `--` separator
static-php-build --extensions tokenizer --out ./php --with-php 8.4 -- --enable-zts

# Use an explicit spc on a host without a bundled one
static-php-build --extensions tokenizer --spc /path/to/spc --out ./php
from static_php_build import BuildRequest, build

report = build(BuildRequest(extensions=["tokenizer", "mbstring"], out="./php"))
print(report.satisfied, report.missing)

Each invocation builds for the host it runs on, so cross-OS coverage means one CI job per OS. A minimal GitHub Actions matrix:

jobs:
  build-php:
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
    runs-on: ${{ matrix.os }}
    steps:
      - run: pipx run static-php-build --extensions tokenizer,mbstring --with-php 8.4 --out dist/php
      - uses: actions/upload-artifact@v4
        with:
          name: php-${{ matrix.os }}
          path: dist/php*

The tool verifies each produced binary via its own php -m read; a non-CLI artifact fails verification and raises. The handoff to static-php-py is the produced binary on disk, loaded at runtime through PHP.local. Full workflow (bundling the artifacts into per-OS wheels): ../../docs/llms/bundling-pipeline.md.

API

Command

static-php-build (--extensions NAMES | --manifest MODULE:ATTR) [--out PATH] [--spc PATH] [--with-php VERSION] [-- <spc args>]

  • --extensions — the required set as comma-separated extension names.
  • --manifest — MODULE:ATTR naming an importable object exposing extensions (a consumer's Requirements constant); exactly one of --extensions and --manifest is required.
  • --out — file path receives the binary; directory path receives php/php.exe inside it. Omitted: ./php (./php.exe on Windows).
  • --spc — explicit spc binary; supersedes the bundled spc for the run.
  • --with-php — major.minor PHP version pinned on spc's download step. Omitted: spc default.
  • -- <spc args> — forwarded to spc's build step verbatim; the tool's own flags are never forwarded.
  • Exit codes: 0 success, 1 runtime failure (BuildError), 2 misuse (no extension set resolvable).

Function

build(request: BuildRequest | None = None) -> ExtensionReport

Produces a host binary loading the required extensions, verifies it, writes it to the destination, and returns the report.

  • BuildRequest — frozen data holder grouping the build inputs: extensions, manifest, out, spc, php_version, spc_args, timeout. Exactly one of extensions and manifest names the required set.
  • ExtensionReport — frozen data holder: required, loaded, missing, satisfied.

Exceptions

  • BuildError — base (distinct from static-php-py's PHPError).
  • ProvisioningError — spc download/build failed, output binary absent, or a required extension is missing.
  • UnsupportedHostError — no bundled spc for the host and no --spc supplied; names --spc as the remedy.

Full design: docs/design.md. Concepts: docs/concept.md. Doc index: docs/index.md.

For Agents

Agent-consumable documentation index at ../../docs/llms.txt (llmstxt.org format).

Citation

If you use this project in academic work, cite our paper. BibTeX (placeholder until the paper is released):

@misc{static_php_py_placeholder,
  title  = {{TODO: paper title — not yet released}},
  author = {{TODO: authors}},
  year   = {{TODO}},
  note   = {Paper not yet released. Citation entry will be updated on publication.}
}

License

GPL-2.0 — see LICENSE. Built binaries are produced by static-php-cli.

Metadata

Release files for static-php-build 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for static-php-build 0.2.0
File Actions
static_php_build-0.2.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for static_php_build-0.2.0-py3-none-win_amd64.whl
static_php_build-0.2.0-py3-none-manylinux_2_17_x86_64.musllinux_1_1_x86_64.whl Python 3 none Linux musl 1.1+ x86-64, Linux glibc 2.17+ x86-64 Details for static_php_build-0.2.0-py3-none-manylinux_2_17_x86_64.musllinux_1_1_x86_64.whl
static_php_build-0.2.0-py3-none-manylinux_2_17_aarch64.musllinux_1_1_aarch64.whl Python 3 none Linux musl 1.1+ ARM64, Linux glibc 2.17+ ARM64 Details for static_php_build-0.2.0-py3-none-manylinux_2_17_aarch64.musllinux_1_1_aarch64.whl
static_php_build-0.2.0-py3-none-macosx_11_0_x86_64.whl Python 3 none macOS 11.0+ x86-64 Details for static_php_build-0.2.0-py3-none-macosx_11_0_x86_64.whl
static_php_build-0.2.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for static_php_build-0.2.0-py3-none-macosx_11_0_arm64.whl

Total release size: 23.5 MB

Release files / static_php_build-0.2.0-py3-none-win_amd64.whl

Download URL static_php_build-0.2.0-py3-none-win_amd64.whl
Size 4.9 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
19708fa21a868bb4f38ccc1051cb78a186b40baa6673aeb55eb2b883fe1c62e5
BLAKE2b-256 checksum
How to use checksums
1b11c3261bc0642974d7cf1e96c3f962d1d89ed998362943311878e9149c952e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / static_php_build-0.2.0-py3-none-manylinux_2_17_x86_64.musllinux_1_1_x86_64.whl

Download URL static_php_build-0.2.0-py3-none-manylinux_2_17_x86_64.musllinux_1_1_x86_64.whl
Size 4.2 MB
Tags Linux glibc 2.17+ x86-64 Linux musl 1.1+ x86-64 Python 3
SHA-256 checksum
How to use checksums
f37cb72c01bb6e988f9fcc1015941e9f41b4a351185ae6fd2a1e85034c9d6f84
BLAKE2b-256 checksum
How to use checksums
cdd2d9db63a19c44118aa2343ceb84de60cb09b00dd079ed026a92eb09bbe78f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / static_php_build-0.2.0-py3-none-manylinux_2_17_aarch64.musllinux_1_1_aarch64.whl

Download URL static_php_build-0.2.0-py3-none-manylinux_2_17_aarch64.musllinux_1_1_aarch64.whl
Size 4.3 MB
Tags Linux glibc 2.17+ ARM64 Linux musl 1.1+ ARM64 Python 3
SHA-256 checksum
How to use checksums
3a337b01516ddbc27f8fdca96dd31f3eaa0b7e8940fa145bdefe7a51390a8b21
BLAKE2b-256 checksum
How to use checksums
373fddea6ce31f02d7a6530595cf78c02c430c3007288e9e89949f0d71297acd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / static_php_build-0.2.0-py3-none-macosx_11_0_x86_64.whl

Download URL static_php_build-0.2.0-py3-none-macosx_11_0_x86_64.whl
Size 5.0 MB
Tags Python 3 macOS 11.0+ x86-64
SHA-256 checksum
How to use checksums
b63d9e9460ba958712f1937ba0e76257fc27d13b360dd493182c21e786046252
BLAKE2b-256 checksum
How to use checksums
c9d054e400bcd0a8ada2c0c639827d35d2183dee013bac7620c236947d0fd772
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / static_php_build-0.2.0-py3-none-macosx_11_0_arm64.whl

Download URL static_php_build-0.2.0-py3-none-macosx_11_0_arm64.whl
Size 4.9 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
bf9f696284e2b29801547f8434ed23cd7ca2c2fd2317778300136a272399aea8
BLAKE2b-256 checksum
How to use checksums
6b0afde4dcc98b6cf1a71d060f60310a0f07b88e9f3bb662e88737a7bff954c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Security for static-php-build 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page