Skip to content

Inject into CLI services

Compare
Choose a tag to compare
@pretzlaw pretzlaw released this 18 Feb 13:12
0bf7a67

New WP-CLI commands can be introduced using the CliCommand::class. Unfortunately it was almost impossible to inject services or parameter from the container. With this patch we implemented and documented an easier way to inject services into CLI-Commands.

  • CLI-Command-Services are no longer lazy as wp-cli needs the direct object/class for its features (e.g. help text)
  • CLI-Command-Services are only available when working on the shell (to spare costs of web calls)