Skip to content

prune only the php binary archives, not the whole bin dir#121

Merged
simonhamp merged 1 commit into
fix-custom-php-binary-prunefrom
fix-custom-php-binary-prune-patch-1
Jun 3, 2026
Merged

prune only the php binary archives, not the whole bin dir#121
simonhamp merged 1 commit into
fix-custom-php-binary-prunefrom
fix-custom-php-binary-prune-patch-1

Conversation

@gwleuverink
Copy link
Copy Markdown
Collaborator

@gwleuverink gwleuverink commented Jun 2, 2026

A small follow-up to #117. That stopped the app from being deleted, but as @bmckay959 spotted the binaries were still ending up in the bundle (his build went from 127MB to 212MB).

php.js extracts the one binary we need into the app's build/php resources during the build, so the php-*.zip files left in the copied source tree are redundant. The previous approach removed the whole binary directory to clear them, which had two problems: on a root path (NATIVEPHP_PHP_BINARY_PATH=./) there's nothing to remove without taking the app with it, so it skipped and left every archive behind; and elsewhere it could delete files a user keeps alongside the binaries.

This targets only the archives we manage, at their fixed bin/{os}/{arch}/php-*.zip location, never the containing directory. The build stays small, unrelated files in bin/ survive, and the path collapse is gone since app/./bin normalises to app/bin rather than the app root.

Reworked the two tests to assert the archives are pruned while the app (and an unrelated bin/ file) survive, instead of asserting the binaries are kept. Checked against the default, a custom subdir, and the root ./ path.

Full suite passes, Pint and PHPStan clean.

php.js copies the one binary we need into the build resources, so the php-*.zip files left in the source tree are dead weight. We were removing the whole binary directory to clear them, which shipped every unused archive on a root path and could take the app down with it.

Target just the archives we manage (bin/{os}/{arch}/php-*.zip) so the build stays small, a user's other files in bin/ survive, and a root path no longer wipes the app (#115).
@simonhamp
Copy link
Copy Markdown
Member

Thanks for cleaning this up @gwleuverink 🙏🏼

@simonhamp simonhamp merged commit bdc6011 into fix-custom-php-binary-prune Jun 3, 2026
3 checks passed
@simonhamp simonhamp deleted the fix-custom-php-binary-prune-patch-1 branch June 3, 2026 01:19
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