Require project autoloader in wp-cli.yml #636
Merged
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.
If you're using the global WP-CLI, it won't include the project's Composer autoloader until WordPress itself loads and Bedrock's own code to include the autoloader happens. This means that if you require third-party WP-CLI commands in a project and attempt to run them via a global copy of WP-CLI, those commands will not load before WordPress, even if they should (via
@when before_wp_load
).Use case:
composer require aaemnnosttv/wp-cli-dotenv-command
wp help
dotenv
under available commandswp dotenv init --template=.env.example --with-salts
(this command is configured to be available before_wp_load)Expected behavior:
Create .env file from template
Actual behavior:
Error because database could not be reached
Requiring the local autoloader as part of WP-CLI's configuration makes commands available when they're supposed to be available, regardless of which instance of WP-CLI you're using.