Repository navigation
Add --extensions-dir flag to load PHP extension config from filesystem - #126
Merged
Merged
Conversation
Add support for loading PHP extension YAML files from an external directory instead of from the compiled-in embedded assets. This is the first step toward moving extension version ownership from binary-builder to the php-buildpack repository. Changes: - Add LoadFromDir(dir, phpMajor, phpMinor) to internal/php/extensions.go. Reads base + patch YAML files from a filesystem directory using the same naming convention as the embedded assets. Extract shared parsing logic into loadFromData() used by both Load() and LoadFromDir(). - Add --extensions-dir CLI flag to cmd/binary-builder/main.go. When set, the PHP recipe loads extensions from this directory. When empty (default), the embedded assets are used — fully backward compatible. - Thread ExtensionsDir through PHPRecipe so the Build() method can dispatch to LoadFromDir() or Load() as appropriate. - Add 5 unit tests for LoadFromDir(): - Base-only (no patch file) - Base + patch with exclusions and additions - Missing base file returns error - Missing patch file is not an error - LoadFromDir on the real assets/ directory matches embedded Load() This is Phase 1 of the PHP extension config migration plan (docs/php-extensions-migration-plan.md in buildpacks-ci). No existing behavior is changed — the --extensions-dir flag is entirely optional.
…date --extensions-dir early Review finding fixes for PR #126: 1. LoadFromDir: distinguish os.IsNotExist from other ReadFile errors on patch files. Previously all errors were silently swallowed; now only missing files are tolerated. Other errors (permissions, I/O) are returned. New test: TestLoadFromDir_PatchFileReadError. 2. PHPRecipe: add ExtensionsDir dispatch tests that verify the recipe loads extensions from a custom directory (not embedded defaults) when ExtensionsDir is set, and returns a clear error when the directory has no base file. 3. loadFromData: replace 'patchData == nil' with 'len(patchData) == 0' to make the nil/empty contract explicit and robust against future callers passing an empty []byte{} instead of nil. 4. main.go: add os.Stat + IsDir check for --extensions-dir immediately after flag parsing, before any expensive build steps. Fails fast with a clear error on misconfigured invocations. 5. Add weekly GitHub Actions workflow (check-php-extensions.yml) that runs bump-versions.rb in dry-run mode and creates/updates a GitHub issue when PECL extensions are outdated. 6. Update AGENTS.md key files table and extensions.go package doc to document LoadFromDir and the --extensions-dir flag.
This was referenced Oct 28, 2026
…ML source Update the weekly check-php-extensions workflow to: 1. Check out php-buildpack alongside binary-builder and buildpacks-ci. 2. Auto-detect the extension YAML directory with fallback chain: php-buildpack/config/extensions > internal/php/assets > internal/php/testdata 3. Set EXTENSIONS_DIR (instead of BINARY_BUILDER_DIR) so the scripts work correctly across all migration phases, including after Phase 5 when assets/ is renamed to testdata/. 4. Update the issue body Next Steps to be repo-agnostic.
tnikolova82
added a commit
that referenced
this pull request
Oct 28, 2026
…se 5)
Remove the go:embed-based extension loading from binary-builder. Extension
YAML files now live exclusively in the php-buildpack repo (config/extensions/)
and must be passed via --extensions-dir during PHP builds.
Changes:
1. Move internal/php/assets/ to internal/php/testdata/. The YAML files
are now test fixtures only, not compiled into the binary.
2. Remove go:embed infrastructure from extensions.go: the embedded FS,
init() function, regex matchers, and embeddedBases/embeddedPatches
maps are all removed. LoadFromDir is the sole production API.
3. Load() now delegates to LoadFromDir("testdata", ...) and is
documented as a test-only convenience function.
4. PHPRecipe.ExtensionsDir is now required. Build() returns a clear
error when it is empty: "--extensions-dir is required for PHP builds".
5. All php_test.go tests updated to pass ExtensionsDir. New test
TestPHPRecipeBuildRequiresExtensionsDir verifies the error path.
6. AGENTS.md updated to reflect the new structure.
DO NOT MERGE until Phase 3 (buildpacks-ci pipeline passing --extensions-dir)
has been running successfully in production for at least one full PHP release
cycle.
Prerequisites:
- binary-builder PR #126 (Phase 1) — merged
- php-buildpack PR #1332 (Phase 2) — merged
- buildpacks-ci Phase 3 PR — merged and validated
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds support for loading PHP extension YAML files from an external directory instead of from the compiled-in embedded assets. This is Phase 1 of the PHP extension config migration — moving extension version ownership from binary-builder to the php-buildpack.
Motivation
binary-builder is a generic compilation tool and should not own buildpack-specific configuration. Today, bumping a PECL extension version requires a binary-builder commit and recompilation. This change decouples the two by allowing the extension config to be passed in at build time.
Changes
internal/php/extensions.goLoadFromDir(dir, major, minor)that reads YAML from filesystem; extract sharedloadFromData()cmd/binary-builder/main.go--extensions-dirflag; thread it toPHPRecipeviabuildRegistry()internal/recipe/php.goExtensionsDirfield toPHPRecipe; dispatch toLoadFromDirorLoadinternal/php/extensions_test.goLoadFromDirBackward compatibility
Fully backward compatible. When
--extensions-diris not set (the default), the embedded assets are used exactly as before. No existing CI pipeline, CLI invocation, or test is affected.Usage
Tests
5 new unit tests:
TestLoadFromDir_BaseOnly— loads base file without a patchTestLoadFromDir_WithPatch— applies exclusions and additions from a patch fileTestLoadFromDir_MissingBaseFile— returns clear error when base file is missingTestLoadFromDir_MissingPatchIsOK— missing patch file is not an errorTestLoadFromDir_MatchesEmbeddedLoad— verifies LoadFromDir onassets/produces identical results to the embeddedLoad()Next steps
This is Phase 1 of the migration plan (see
buildpacks-ci/docs/php-extensions-migration-plan.md):php-buildpack/config/extensions/--extensions-dirduring PHP builds