funkjedi/composer-include-files
Composer plugin that lets you include arbitrary PHP files, such as helper functions or bootstrap scripts, via the extra section of composer.json. They load automatically on every request, no need to package them as a library or manually require them.
composer require funkjedi/composer-include-files — this installs a Composer plugin, so it must be in require (not require-dev)."config": { "allow-plugins": { "funkjedi/composer-include-files": true } }
extra.include_files on a package (or the root project):
"extra": { "include_files": ["bootstrap/functions.php"] }
composer dump-autoload and inspect the generated vendor/composer/include_files.php plus vendor/composer/autoload_files.php to confirm your files are wired ahead of normal autoload.files.First real use case: WordPress plugins/themes or legacy libraries where a bootstrap file must run before anything declared in other packages' autoload.files (constants, helper functions, polyfills that later files assume exist).
extra.include_files. Consumers get the correct load order automatically — no require in their app bootstrap, no instruction in the README.composer.json under extra.include_files. This is also the way to get deterministic ordering: put one aggregator file in the array that require_onces the rest in the order you want.autoload_files bootstrap, the preloaded files run whenever vendor/autoload.php runs — so Laravel's index.php, a WordPress wp-load shim, or a CLI entrypoint will pick them up without extra glue.post-autoload-dump) or maintain separate root composer.json variants; don't expect env-based toggling.composer install --no-dev --optimize-autoloader (or at minimum dump-autoload) during deploy/CI so the generated file matches the lock file. Commit vendor/ only if you also commit the regenerated include file.allow-plugins is the #1 cause of "package installed but nothing happened." Check the install output for "Plugin ... was skipped."composer-plugin-api constraint accepts your Composer 2.x version before relying on it. Pin the version and test upgrades.vendor/composer/include_files.php — it's regenerated on every install/update/dump and your changes vanish.require.--no-scripts / COMPOSER_SKIP_SCRIPTS skips post-autoload-dump; the generated file goes stale or missing, and you'll chase a load-order bug that's really a build bug.requires the same file, use require_once to avoid redefining functions/classes.COMPOSER_DEBUG_EVENTS=1 composer dump-autoload -vvv, then read vendor/composer/include_files.php and grep autoload_files.php for your paths.extra.include_files is the recommended extension point for code you don't own; it keeps the override visible in version control instead of buried in vendor.require_onces the same files before vendor/autoload.php is a drop-in replacement when you outgrow the plugin.How can I help you explore Laravel packages today?