Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require project autoloader in wp-cli.yml #636

Merged
merged 2 commits into from
Apr 24, 2024

Conversation

ethanclevenger91
Copy link
Contributor

@ethanclevenger91 ethanclevenger91 commented Apr 28, 2022

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:

  • Have WP-CLI available globally via their install instructions
  • Create a Bedrock project
  • composer require aaemnnosttv/wp-cli-dotenv-command
  • Run wp help
  • See dotenv under available commands
  • Run wp 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.

@ethanclevenger91
Copy link
Contributor Author

Related: aaemnnosttv/wp-cli-dotenv-command#12

@retlehs retlehs merged commit 566407b into roots:master Apr 24, 2024
4 checks passed
retlehs added a commit that referenced this pull request May 7, 2024
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.

4 participants