Config Files
WP-CLI has a number of global parameters (for example, --path=<path> and --user=<user>). These parameters are called global because they affect WP-CLI’s interaction with WordPress and have the same behavior for all commands.
Default values for such global parameters can be set via the configuration file wp-cli.yml. In addition to global parameters, this file can also specify other options that indicate how WP-CLI should operate.
WP-CLI can automatically discover and read parameters from multiple configuration files (if present). The order in which configuration files are checked (the first existing file takes effect, unless it specifies the parameter merge: true):
- File
wp-cli.local.ymlin the working directory (or above). - File
wp-cli.ymlin the working directory (or above). - File
~/.wp-cli/config.yml(the path can be changed by setting the environment variable WP_CLI_CONFIG_PATH).
A simple example of a wp-cli.yml file:
url: http://example.com user: admin
In addition to global parameters, the configuration file can contain default values for individual commands. You can also set aliases for different WordPress installations here.
Example of a wp-cli.yml file (with comments):
# Global Default parameters path: wp-core url: http://example.com user: admin color: false # Disable unnecessary commands disabled_commands: - db drop - plugin install # Load your own command file require: - path-to/command.php # Default parameters for the `wp config create` command config create: dbuser: root dbpass: extra-php: | define( 'WP_DEBUG', true ); define( 'WP_POST_REVISIONS', 50 ); # Alias to other WordPress installations # Example usage: $ wp @staging rewrite flush # Possible fields when creating an alias: user, url, path, ssh, http @staging: ssh: [email protected] user: wpcli path: /srv/www/staging.wp-cli.org @production: ssh: [email protected]:2222 user: wpcli path: /srv/www/wp-cli.org # Aliases can refer to other aliases. # This way you can create a group of aliases. # Alias groups can be nested in other aliases (can be nested) @both: - @staging - @production # '_' is a special value that denotes configuration parameters for this wp-cli.yml _: # Merge default sub-command values from upstream ~/.wp-cli/config.yml, rather than overwrite them merge: true # Inherit configuration from an arbitrary YAML file inherit: prod.yml
--
Also read in the official docs: https://make.wordpress.org/cli/handbook/references/config/