Skip to content

NextPDF backport integration

Build tooling only, not a runtime dependency. Maintainers use this package to produce the PHP (PHP: Hypertext Preprocessor) 7.4 and PHP 8.1 backport distributions of NextPDF. Applications must never add this package as a runtime dependency.

There are two distinct integration points. You integrate the builder repository into the build host release flow. A downstream application integrates only the produced package, nextpdf/backport, into its dependency tree. The builder never enters an application’s dependency tree.

Because the builder declares "type": "project" in composer.json, treat it as a project repository, not a library. Integrate it by cloning the repository and running a dev install, not with composer require:

Terminal window
git clone https://github.com/nextpdf-labs/backport.git
cd backport
git checkout PHP74
composer install --prefer-dist --no-progress

Check out the branch for the target you plan to produce. Use PHP74 (the default) for the PHP 7.4 core-only distribution. Use PHP81 for the PHP 8.1 distribution with all adapters. Do not pass --no-dev. The build requires the Rector engine, PHPStan, and PHPUnit; those are dev dependencies. Verified against composer.json (type, require-dev) and the dual-branch model in /integrations/backport/overview/.

The builder has no framework auto-discovery. At build time, scripts/build.php loads Rector and the three custom abstract syntax tree rules through explicit require_once calls and Composer PHP Standards Recommendation 4 (PSR-4) autoloading. The full boot sequence and source module discovery are documented in /integrations/backport/boot-and-discovery/.

Not applicable. The builder is a command-line interface (CLI) tool with no dependency-injection container. Verified against the repository structure and composer.jsonautoload.

The “publish configuration” is not a separate file. It is the set of build flags and the fixed package definitions in scripts/adjust-composer.php:

  • Target map. --target=php81 produces nextpdf/backport (constraint >=8.1 <8.5, replaces core, the adapters, and compat-legacy) and, when included, nextpdf/backport-pro. --target=php74 produces nextpdf/backport (constraint >=7.4 <8.1, replaces only nextpdf/core) and no Pro.
  • Exclusion. --no-pro excludes the Pro package on the PHP 8.1 target. By construction, the PHP 7.4 target excludes Pro and all adapters.
  • Version. The build writes --version (or the release tag after stripping the leading v) into the generated composer.json and CHANGELOG.md.

This behavior is verified against scripts/build.php and scripts/adjust-composer.php (generatePublicComposer(), generateProComposer(), buildReplace()). The complete flag reference is in /integrations/backport/configuration/.

You integrate the builder into a release flow through the GitHub Actions workflows in .github/workflows/. 0-ci.yml gates every change to each permanent branch with PHPStan, the rule tests, and a dry-run. build.yml produces and releases the distribution when it receives a source-release repository-dispatch event or a manual dispatch. The full operating model — triggers, lanes, validation matrix, and the shared release — is documented in /integrations/backport/production-usage/.

The release pipeline is the integration smoke test. After the build completes, the workflow switches the runner to the target PHP and runs php -l across the emitted source. It then installs and exercises the produced package across the validation matrix (PHP 8.1–8.4 for the PHP 8.1 lane, PHP 7.4 and 8.0 for the PHP 7.4 lane). A distribution that a target runtime rejects does not reach a release. Verified against .github/workflows/build.yml (the syntax-check and validate-* jobs). You can smoke-test locally produced output the same way with the Docker command the validation stage prints — see /integrations/backport/quickstart/.

The builder’s public surface is the CLI orchestrator and its Composer script aliases, not a bin/ executable.

Entry pointResolves toPurpose
composer buildphp scripts/build.phpRun the full build
composer build:dryphp scripts/build.php --dry-runRun a dry-run build
composer testphpunitRun the rule fixture suites
composer analysephpstan analyse rector/rules scripts --level=10Analyze the build code

Verified against composer.jsonscripts. The downstream package exposes the original NextPDF\ application programming interface (API) symbols, unchanged by the backport. The package replaces the source packages and autoloads the merged tree through the single PSR-4 prefix.

  • /integrations/backport/overview/ — what the builder is and what it produces.
  • /integrations/backport/boot-and-discovery/ — boot sequence and source discovery.
  • /integrations/backport/install/ — build-host and downstream installation.
  • /integrations/backport/production-usage/ — the release pipeline.