Download the PHP package pollora/wp-cli without Composer
On this page you can find all versions of the php package pollora/wp-cli. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download pollora/wp-cli
More information about pollora/wp-cli
Files in pollora/wp-cli
Package wp-cli
Short Description WP-CLI commands declared with PHP attributes: a class with #[WpCli], subcommands with #[Command], synopsis, hooks and conditions as attributes. Runs with or without Laravel.
License MIT
Homepage https://pollora.dev/advanced/wp-cli/
Informations about the package wp-cli
WP-CLI commands written as classes: #[WpCli] on a class registers it, its public methods become subcommands, and the command and subcommand names come from the class and method names unless you give them. Synopsis, when, before and after callbacks are attributes too; no WP_CLI::add_command() call to write.
Part of Pollora, the Laravel framework for WordPress, where it is installed and wired for you, with a
pollora:make:wp-cligenerator: see WP-CLI Commands. It runs without Laravel too, in a WordPress plugin, a Bedrock site or any PHP project.
Installation
Requires PHP 8.3+. It builds on pollora/attributes and pollora/discovery. WP-CLI itself provides the WP_CLI classes when it runs.
Declaring commands
- The command name is the class name in kebab case, without its
Commandsuffix:ReportsCommand→reports.#[WpCli('reports')]sets it. A class with__invoke()is a single command. - A method with
#[Command]is a subcommand registered by this package:#[Command('rm')]names it, and its#[Synopsis],#[When],#[BeforeInvoke],#[AfterInvoke]and#[IsDeferred]become the matchingWP_CLI::add_command()arguments. - WP-CLI also runs the class's other public methods as subcommands, under their method name, with their help read from the docblock.
- The class is built once, with its constructor dependencies, and that instance runs every command and subcommand.
Wiring it outside Pollora
Run the discovery engine with WpCliDiscovery when WP-CLI loads your plugin:
Commands are built by the engine's instance resolver: by reflection by default (constructor parameters typed with a class are built in turn), by your container if you give the engine a ContainerInstanceResolver (PSR-11). WpCliService and WpCliDiscovery take a PSR-3 logger.
Testing
License
MIT. See LICENSE.
All versions of wp-cli with dependencies
pollora/attributes Version ^0.1 || ^1.0
pollora/discovery Version ^0.1 || ^0.2 || ^0.3 || ^1.0
psr/log Version ^3.0