Release builds
Prefixing needs Composer's dev dependencies: Strauss pulls in composer/composer and more,
which install into vendor/ alongside your autoloader. Zip vendor/ as it is and the plugin
comes out around 230 MB. A release needs only a few of those files.
The recipe
- Run a full
composer install, so Strauss runs and writesvendor-prefixed/. - Regenerate the autoloader for production:
composer dump-autoload --no-dev --classmap-authoritative - Copy only what runs:
- your main file,
src/and any other runtime files (templates, languages,readme.txt) vendor-prefixed/vendor/autoload.php- the top-level files of
vendor/composer/(autoload_*.php,ClassLoader.php,installed.php, ...), without any of its subdirectories
- your main file,
- Check the result. Fail the build if
Bignall\WPFoundation\appears anywhere without your prefix in front of it. That means a reference Strauss didn't rewrite, and the plugin would fatally error, or load another plugin's copy of the library. - Restore your development autoloader with
composer dump-autoload.
A real plugin built this way came out at 77 files and 358 KB.
The script
The example plugin ships this recipe as
bin/build-release.sh. Copy it into your
plugin and list your runtime files in RUNTIME_FILES:
bin/build-release.sh
# ...
# Built build/acme-bookings.zip
# 43 files, 448K
It also checks that the survey's script made it into vendor-prefixed/, lints every PHP file,
and always restores the development autoloader, even when the build fails.
Add /build/ to your .gitignore.