PHP Class Package_Command, wp-cli

WP-CLI packages are community-maintained projects built on WP-CLI. They can contain WP-CLI commands, but they can also just extend WP-CLI in some way. Installable packages are listed in the Package Index. Learn how to create your own command from the Commands Cookbook ## EXAMPLES # List installed packages $ wp package list +-----------------------+------------------------------------------+---------+------------+ | name | description | authors | version | +-----------------------+------------------------------------------+---------+------------+ | wp-cli/server-command | Start a development server for WordPress | | dev-master | +-----------------------+------------------------------------------+---------+------------+ # Install the latest development version of the package $ wp package install wp-cli/server-command Installing wp-cli/server-command (dev-master) Updating /home/person/.wp-cli/packages/composer.json to require the package... Using Composer to install the package... --- Loading composer repositories with package information Updating dependencies Resolving dependencies through SAT Dependency resolution completed in 0.005 seconds Analyzed 732 packages to resolve dependencies Analyzed 1034 rules to resolve dependencies - Installing package Writing lock file Generating autoload files --- Success: Package installed successfully. # Uninstall package $ wp package uninstall wp-cli/server-command Removing require statement from /home/person/.wp-cli/packages/composer.json Deleting package directory /home/person/.wp-cli/packages/vendor/wp-cli/server-command Regenerating Composer autoload. Success: Uninstalled package.
Inheritance: extends WP_CLI_Command
Mostrar archivo Open project: wp-cli/wp-cli

Public Methods

Method Description
browse ( $_, $assoc_args ) Browse WP-CLI packages available for installation.
install ( $args, $assoc_args ) Install a WP-CLI package.
list_ ( $args, $assoc_args ) List installed WP-CLI packages.
path ( $args ) Get the path to an installed WP-CLI package, or the package directory.
uninstall ( $args ) Uninstall a WP-CLI package.
update ( ) Update all installed WP-CLI packages to their latest version.

Private Methods

Method Description
create_default_composer_json ( string $composer_path ) : true | WP_Error Create a default composer.json, should one not already exist
find_latest_package ( Composer\Package\PackageInterface $package, Composer\Composer $composer, string $phpVersion, boolean $minorOnly = false ) : Composer\Package\PackageInterface | null Given a package, this finds the latest package matching it
get_community_package_by_name ( $package_name ) Get a community package by its name.
get_community_packages ( ) : array Get all of the community packages.
get_composer ( ) Get a Composer instance.
get_composer_json ( ) Get the composer.json object
get_composer_json_path ( ) Get the path to composer.json
get_installed_package_by_name ( $package_name ) Get an installed package by its name.
get_installed_packages ( ) Get the installed community packages.
get_package_name_and_version_from_dir_package ( string $dir_package ) : string Get the name of the package from the composer.json in a directory path
get_pool ( Composer\Composer $composer )
get_wp_cli_version_composer ( ) Get the WP-CLI version for composer.json
is_community_package ( object $package ) : boolean Check whether a package is a WP-CLI community package based on membership in our package index.
is_package_installed ( $package_name ) Check if the package name provided is already installed.
package_index ( ) : Composer\Repository\ComposerRepository Get the package index instance
show_packages ( string $context, $packages, $assoc_args ) Display a set of packages

Method Details

browse() public method

Lists packages available for installation from the Package Index. ## OPTIONS [--fields=] : Limit the output to specific fields. Defaults to all fields. [--format=] : Render output in a particular format. --- default: table options: - table - csv - ids - json - yaml --- ## AVAILABLE FIELDS These fields will be displayed by default for each package: * name * description * authors * version There are no optionally available fields. ## EXAMPLES $ wp package browse --format=yaml --- 10up/mu-migration: name: 10up/mu-migration description: A set of WP-CLI commands to support the migration of single WordPress instances to multisite authors: Nícholas André version: dev-master, dev-develop aaemnnosttv/wp-cli-dotenv-command: name: aaemnnosttv/wp-cli-dotenv-command description: Dotenv commands for WP-CLI authors: Evan Mattson version: v0.1, v0.1-beta.1, v0.2, dev-master, dev-dev, dev-develop, dev-tests/behat aaemnnosttv/wp-cli-http-command: name: aaemnnosttv/wp-cli-http-command description: WP-CLI command for using the WordPress HTTP API authors: Evan Mattson version: dev-master
public browse ( $_, $assoc_args )

install() public method

Packages are required to be a valid Composer package, and can be specified as: * Package name from WP-CLI's package index. * Git URL accessible by the current shell user. * Path to a directory on the local machine. * Local or remote .zip file. When installing a local directory, WP-CLI simply registers a reference to the directory. If you move or delete the directory, WP-CLI's reference breaks. When installing a .zip file, WP-CLI extracts the package to ~/.wp-cli/packages/local/. ## OPTIONS : Name, git URL, directory path, or .zip file for the package to install. Names can optionally include a version constraint (e.g. wp-cli/server-command:@stable). ## EXAMPLES # Install the latest development version from the package index. $ wp package install wp-cli/server-command Installing package wp-cli/server-command (dev-master) Updating /home/person/.wp-cli/packages/composer.json to require the package... Using Composer to install the package... --- Loading composer repositories with package information Updating dependencies Resolving dependencies through SAT Dependency resolution completed in 0.005 seconds Analyzed 732 packages to resolve dependencies Analyzed 1034 rules to resolve dependencies - Installing package Writing lock file Generating autoload files --- Success: Package installed. # Install the latest stable version. $ wp package install wp-cli/server-command:@stable # Install a package hosted at a git URL. $ wp package install [email protected]:runcommand/hook.git # Install a package in a .zip file. $ wp package install google-sitemap-generator-cli.zip
public install ( $args, $assoc_args )

list_() public method

## OPTIONS [--fields=] : Limit the output to specific fields. Defaults to all fields. [--format=] : Render output in a particular format. --- default: table options: - table - csv - ids - json - yaml --- ## AVAILABLE FIELDS These fields will be displayed by default for each package: * name * authors * version * update * update_version These fields are optionally available: * description ## EXAMPLES $ wp package list +-----------------------+------------------------------------------+---------+------------+ | name | description | authors | version | +-----------------------+------------------------------------------+---------+------------+ | wp-cli/server-command | Start a development server for WordPress | | dev-master | +-----------------------+------------------------------------------+---------+------------+
public list_ ( $args, $assoc_args )

path() public method

If you want to contribute to a package, this is a great way to jump to it. ## OPTIONS [] : Name of the package to get the directory for. ## EXAMPLES # Get package path $ wp package path home/person/.wp-cli/packages/ # Change directory to package path $ cd $(wp package path) && pwd home/vagrant/.wp-cli/packages
public path ( $args )

uninstall() public method

## OPTIONS : Name of the package to uninstall. ## EXAMPLES $ wp package uninstall wp-cli/server-command Removing require statement from /home/person/.wp-cli/packages/composer.json Deleting package directory /home/person/.wp-cli/packages/vendor/wp-cli/server-command Regenerating Composer autoload. Success: Uninstalled package.
public uninstall ( $args )

update() public method

## EXAMPLES $ wp package update Using Composer to update packages... --- Loading composer repositories with package information Updating dependencies Resolving dependencies through SAT Dependency resolution completed in 0.074 seconds Analyzed 1062 packages to resolve dependencies Analyzed 22383 rules to resolve dependencies Writing lock file Generating autoload files --- Success: Packages updated.
public update ( )