2017 © Pedro PelĂĄez
 

wp-cli-package config-command

Generates and reads the wp-config.php file.

image

wp-cli/config-command

Generates and reads the wp-config.php file.

  • Thursday, July 26, 2018
  • by danielbachhuber
  • Repository
  • 6 Watchers
  • 12 Stars
  • 258,884 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 13 Forks
  • 3 Open issues
  • 19 Versions
  • 22 % Grown

The README.md

wp-cli/config-command

Generates and reads the wp-config.php file., (*1)

Testing, (*2)

Quick links: Using | Installing | Contributing | Support, (*3)

Using

This package implements the following commands:, (*4)

wp config

Generates and reads the wp-config.php file., (*5)

wp config

EXAMPLES, (*6)

# Create standard wp-config.php file.
$ wp config create --dbname=testing --dbuser=wp --dbpass=securepswd --locale=ro_RO
Success: Generated 'wp-config.php' file.

# List constants and variables defined in wp-config.php file.
$ wp config list
+------------------+------------------------------------------------------------------+----------+
| key              | value                                                            | type     |
+------------------+------------------------------------------------------------------+----------+
| table_prefix     | wp_                                                              | variable |
| DB_NAME          | wp_cli_test                                                      | constant |
| DB_USER          | root                                                             | constant |
| DB_PASSWORD      | root                                                             | constant |
| AUTH_KEY         | r6+@shP1yO&$)1gdu.hl[/j;7Zrvmt~o;#WxSsa0mlQOi24j2cR,7i+QM/#7S:o^ | constant |
| SECURE_AUTH_KEY  | iO-z!_m--YH$Tx2tf/&V,YW*13Z_HiRLqi)d?$o-tMdY+82pK$`T.NYW~iTLW;xp | constant |
+------------------+------------------------------------------------------------------+----------+

# Get wp-config.php file path.
$ wp config path
/home/person/htdocs/project/wp-config.php

# Get the table_prefix as defined in wp-config.php file.
$ wp config get table_prefix
wp_

# Set the WP_DEBUG constant to true.
$ wp config set WP_DEBUG true --raw
Success: Updated the constant 'WP_DEBUG' in the 'wp-config.php' file with the raw value 'true'.

# Delete the COOKIE_DOMAIN constant from the wp-config.php file.
$ wp config delete COOKIE_DOMAIN
Success: Deleted the constant 'COOKIE_DOMAIN' from the 'wp-config.php' file.

# Launch system editor to edit wp-config.php file.
$ wp config edit

# Check whether the DB_PASSWORD constant exists in the wp-config.php file.
$ wp config has DB_PASSWORD
$ echo $?
0

# Assert if MULTISITE is true.
$ wp config is-true MULTISITE
$ echo $?
0

# Get new salts for your wp-config.php file.
$ wp config shuffle-salts
Success: Shuffled the salt keys.

wp config edit

Launches system editor to edit the wp-config.php file., (*7)

wp config edit [--config-file=<path>]

OPTIONS, (*8)

[--config-file=<path>]
    Specify the file path to the config file to be edited. Defaults to the root of the
    WordPress installation and the filename "wp-config.php".

EXAMPLES, (*9)

# Launch system editor to edit wp-config.php file
$ wp config edit

# Edit wp-config.php file in a specific editor
$ EDITOR=vim wp config edit

wp config delete

Deletes a specific constant or variable from the wp-config.php file., (*10)

wp config delete <name> [--type=<type>] [--config-file=<path>]

OPTIONS, (*11)

<name>
    Name of the wp-config.php constant or variable.

[--type=<type>]
    Type of the config value to delete. Defaults to 'all'.
    ---
    default: all
    options:
      - constant
      - variable
      - all
    ---

[--config-file=<path>]
    Specify the file path to the config file to be modified. Defaults to the root of the
    WordPress installation and the filename "wp-config.php".

EXAMPLES, (*12)

# Delete the COOKIE_DOMAIN constant from the wp-config.php file.
$ wp config delete COOKIE_DOMAIN
Success: Deleted the constant 'COOKIE_DOMAIN' from the 'wp-config.php' file.

wp config create

Generates a wp-config.php file., (*13)

wp config create --dbname=<dbname> --dbuser=<dbuser> [--dbpass=<dbpass>] [--dbhost=<dbhost>] [--dbprefix=<dbprefix>] [--dbcharset=<dbcharset>] [--dbcollate=<dbcollate>] [--locale=<locale>] [--extra-php] [--skip-salts] [--skip-check] [--force] [--config-file=<path>] [--insecure]

Creates a new wp-config.php with database constants, and verifies that the database constants are correct., (*14)

OPTIONS, (*15)

--dbname=<dbname>
    Set the database name.

--dbuser=<dbuser>
    Set the database user.

[--dbpass=<dbpass>]
    Set the database user password.

[--dbhost=<dbhost>]
    Set the database host.
    ---
    default: localhost
    ---

[--dbprefix=<dbprefix>]
    Set the database table prefix.
    ---
    default: wp_
    ---

[--dbcharset=<dbcharset>]
    Set the database charset.
    ---
    default: utf8
    ---

[--dbcollate=<dbcollate>]
    Set the database collation.
    ---
    default:
    ---

[--locale=<locale>]
    Set the WPLANG constant. Defaults to $wp_local_package variable.

[--extra-php]
    If set, the command copies additional PHP code into wp-config.php from STDIN.

[--skip-salts]
    If set, keys and salts won't be generated, but should instead be passed via `--extra-php`.

[--skip-check]
    If set, the database connection is not checked.

[--force]
    Overwrites existing files, if present.

[--config-file=<path>]
    Specify the file path to the config file to be created. Defaults to the root of the
    WordPress installation and the filename "wp-config.php".

[--insecure]
    Retry API download without certificate validation if TLS handshake fails. Note: This makes the request vulnerable to a MITM attack.

EXAMPLES, (*16)

# Standard wp-config.php file
$ wp config create --dbname=testing --dbuser=wp --dbpass=securepswd --locale=ro_RO
Success: Generated 'wp-config.php' file.

# Enable WP_DEBUG and WP_DEBUG_LOG
$ wp config create --dbname=testing --dbuser=wp --dbpass=securepswd --extra-php <<PHP
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
PHP
Success: Generated 'wp-config.php' file.

# Avoid disclosing password to bash history by reading from password.txt
# Using --prompt=dbpass will prompt for the 'dbpass' argument
$ wp config create --dbname=testing --dbuser=wp --prompt=dbpass < password.txt
Success: Generated 'wp-config.php' file.

wp config get

Gets the value of a specific constant or variable defined in wp-config.php file., (*17)

wp config get <name> [--type=<type>] [--format=<format>] [--config-file=<path>]

OPTIONS, (*18)

<name>
    Name of the wp-config.php constant or variable.

[--type=<type>]
    Type of config value to retrieve. Defaults to 'all'.
    ---
    default: all
    options:
      - constant
      - variable
      - all
    ---

[--format=<format>]
    Get value in a particular format.
    Dotenv is limited to non-object values.
    ---
    default: var_export
    options:
      - var_export
      - json
      - yaml
      - dotenv
    ---

[--config-file=<path>]
    Specify the file path to the config file to be read. Defaults to the root of the
    WordPress installation and the filename "wp-config.php".

EXAMPLES, (*19)

# Get the table_prefix as defined in wp-config.php file.
$ wp config get table_prefix
wp_

wp config has

Checks whether a specific constant or variable exists in the wp-config.php file., (*20)

wp config has <name> [--type=<type>] [--config-file=<path>]

OPTIONS, (*21)

<name>
    Name of the wp-config.php constant or variable.

[--type=<type>]
    Type of the config value to set. Defaults to 'all'.
    ---
    default: all
    options:
      - constant
      - variable
      - all
    ---

[--config-file=<path>]
    Specify the file path to the config file to be checked. Defaults to the root of the
    WordPress installation and the filename "wp-config.php".

EXAMPLES, (*22)

# Check whether the DB_PASSWORD constant exists in the wp-config.php file.
$ wp config has DB_PASSWORD

wp config is-true

Determines whether value of a specific defined constant or variable is truthy., (*23)

wp config is-true <name> [--type=<type>] [--config-file=<path>]

This determination is made by evaluating the retrieved value via boolval()., (*24)

OPTIONS, (*25)

<name>
    Name of the wp-config.php constant or variable.

[--type=<type>]
    Type of config value to retrieve. Defaults to 'all'.
    ---
    default: all
    options:
      - constant
      - variable
      - all
    ---

[--config-file=<path>]
    Specify the file path to the config file to be read. Defaults to the root of the
    WordPress installation and the filename "wp-config.php".

EXAMPLES, (*26)

# Assert if MULTISITE is true
$ wp config is-true MULTISITE
$ echo $?
0

wp config list

Lists variables, constants, and file includes defined in wp-config.php file., (*27)

wp config list [<filter>...] [--fields=<fields>] [--format=<format>] [--strict] [--config-file=<path>]

OPTIONS, (*28)

[<filter>...]
    Name or partial name to filter the list by.

[--fields=<fields>]
    Limit the output to specific fields. Defaults to all fields.

[--format=<format>]
    Render output in a particular format.
    Dotenv is limited to non-object values.
    ---
    default: table
    options:
      - table
      - csv
      - json
      - yaml
      - dotenv
    ---

[--strict]
    Enforce strict matching when a filter is provided.

[--config-file=<path>]
    Specify the file path to the config file to be read. Defaults to the root of the
    WordPress installation and the filename "wp-config.php".

EXAMPLES, (*29)

# List constants and variables defined in wp-config.php file.
$ wp config list
+------------------+------------------------------------------------------------------+----------+
| key              | value                                                            | type     |
+------------------+------------------------------------------------------------------+----------+
| table_prefix     | wp_                                                              | variable |
| DB_NAME          | wp_cli_test                                                      | constant |
| DB_USER          | root                                                             | constant |
| DB_PASSWORD      | root                                                             | constant |
| AUTH_KEY         | r6+@shP1yO&$)1gdu.hl[/j;7Zrvmt~o;#WxSsa0mlQOi24j2cR,7i+QM/#7S:o^ | constant |
| SECURE_AUTH_KEY  | iO-z!_m--YH$Tx2tf/&V,YW*13Z_HiRLqi)d?$o-tMdY+82pK$`T.NYW~iTLW;xp | constant |
+------------------+------------------------------------------------------------------+----------+

# List only database user and password from wp-config.php file.
$ wp config list DB_USER DB_PASSWORD --strict
+------------------+-------+----------+
| key              | value | type     |
+------------------+-------+----------+
| DB_USER          | root  | constant |
| DB_PASSWORD      | root  | constant |
+------------------+-------+----------+

# List all salts from wp-config.php file.
$ wp config list _SALT
+------------------+------------------------------------------------------------------+----------+
| key              | value                                                            | type     |
+------------------+------------------------------------------------------------------+----------+
| AUTH_SALT        | n:]Xditk+_7>Qi=>BmtZHiH-6/Ecrvl(V5ceeGP:{>?;BT^=[B3-0>,~F5z$(+Q$ | constant |
| SECURE_AUTH_SALT | ?Z/p|XhDw3w}?c.z%|+BAr|(Iv*H%%U+Du&kKR y?cJOYyRVRBeB[2zF-`(>+LCC | constant |
| LOGGED_IN_SALT   | +$@(1{b~Z~s}Cs>8Y]6[m6~TnoCDpE>O%e75u}&6kUH!>q:7uM4lxbB6[1pa_X,q | constant |
| NONCE_SALT       | _x+F li|QL?0OSQns1_JZ{|Ix3Jleox-71km/gifnyz8kmo=w-;@AE8W,(fP<N}2 | constant |
+------------------+------------------------------------------------------------------+----------+

wp config path

Gets the path to wp-config.php file., (*30)

wp config path 

EXAMPLES, (*31)

# Get wp-config.php file path
$ wp config path
/home/person/htdocs/project/wp-config.php

wp config set

Sets the value of a specific constant or variable defined in wp-config.php file., (*32)

wp config set <name> <value> [--add] [--raw] [--anchor=<anchor>] [--placement=<placement>] [--separator=<separator>] [--type=<type>] [--config-file=<path>]

OPTIONS, (*33)

<name>
    Name of the wp-config.php constant or variable.

<value>
    Value to set the wp-config.php constant or variable to.

[--add]
    Add the value if it doesn't exist yet.
    This is the default behavior, override with --no-add.

[--raw]
    Place the value into the wp-config.php file as is, instead of as a quoted string.

[--anchor=<anchor>]
    Anchor string where additions of new values are anchored around.
    Defaults to "/* That's all, stop editing!".
    The special case "EOF" string uses the end of the file as the anchor.

[--placement=<placement>]
    Where to place the new values in relation to the anchor string.
    ---
    default: 'before'
    options:
      - before
      - after
    ---

[--separator=<separator>]
    Separator string to put between an added value and its anchor string.
    The following escape sequences will be recognized and properly interpreted: '\n' => newline, '\r' => carriage return, '\t' => tab.
    Defaults to a single EOL ("\n" on *nix and "\r\n" on Windows).

[--type=<type>]
    Type of the config value to set. Defaults to 'all'.
    ---
    default: all
    options:
      - constant
      - variable
      - all
    ---

[--config-file=<path>]
    Specify the file path to the config file to be modified. Defaults to the root of the
    WordPress installation and the filename "wp-config.php".

EXAMPLES, (*34)

# Set the WP_DEBUG constant to true.
$ wp config set WP_DEBUG true --raw
Success: Updated the constant 'WP_DEBUG' in the 'wp-config.php' file with the raw value 'true'.

wp config shuffle-salts

Refreshes the salts defined in the wp-config.php file., (*35)

wp config shuffle-salts [<keys>...] [--force] [--config-file=<path>] [--insecure]

OPTIONS, (*36)

[<keys>...]
    One ore more keys to shuffle. If none are provided, this falls back to the default WordPress Core salt keys.

[--force]
    If an unknown key is requested to be shuffled, add it instead of throwing a warning.

[--config-file=<path>]
    Specify the file path to the config file to be modified. Defaults to the root of the
    WordPress installation and the filename "wp-config.php".

[--insecure]
    Retry API download without certificate validation if TLS handshake fails. Note: This makes the request vulnerable to a MITM attack.

EXAMPLES, (*37)

# Get new salts for your wp-config.php file
$ wp config shuffle-salts
Success: Shuffled the salt keys.

# Add a cache key salt to the wp-config.php file
$ wp config shuffle-salts WP_CACHE_KEY_SALT --force
Success: Shuffled the salt keys.

Installing

This package is included with WP-CLI itself, no additional installation necessary., (*38)

To install the latest version of this package over what's included in WP-CLI, run:, (*39)

wp package install git@github.com:wp-cli/config-command.git

Contributing

We appreciate you taking the initiative to contribute to this project., (*40)

Contributing isn’t limited to just code. We encourage you to contribute in the way that best fits your abilities, by writing tutorials, giving a demo at your local meetup, helping other users with their support questions, or revising our documentation., (*41)

For a more thorough introduction, check out WP-CLI's guide to contributing. This package follows those policy and guidelines., (*42)

Reporting a bug

Think you’ve found a bug? We’d love for you to help us get it fixed., (*43)

Before you create a new issue, you should search existing issues to see if there’s an existing resolution to it, or if it’s already been fixed in a newer version., (*44)

Once you’ve done a bit of searching and discovered there isn’t an open or fixed issue for your bug, please create a new issue. Include as much detail as you can, and clear steps to reproduce if possible. For more guidance, review our bug report documentation., (*45)

Creating a pull request

Want to contribute a new feature? Please first open a new issue to discuss whether the feature is a good fit for the project., (*46)

Once you've decided to commit the time to seeing your pull request through, please follow our guidelines for creating a pull request to make sure it's a pleasant experience. See "Setting up" for details specific to working on this package locally., (*47)

Support

GitHub issues aren't for general support questions, but there are other venues you can try: https://wp-cli.org/#support, (*48)

This README.md is generated dynamically from the project's codebase using wp scaffold package-readme (doc). To suggest changes, please submit a pull request against the corresponding part of the codebase., (*49)

The Versions

26/07 2018

dev-change-default-db-host

dev-change-default-db-host https://github.com/wp-cli/config-command

Generates and reads the wp-config.php file.

  Sources   Download

MIT

The Requires

 

The Development Requires

26/07 2018

dev-master

9999999-dev https://github.com/wp-cli/config-command

Generates and reads the wp-config.php file.

  Sources   Download

MIT

The Requires

 

The Development Requires

20/04 2018

v1.2.0

1.2.0.0 https://github.com/wp-cli/config-command

Generates and reads the wp-config.php file.

  Sources   Download

MIT

The Requires

 

The Development Requires

20/04 2018

dev-refresh-scaffold-files

dev-refresh-scaffold-files https://github.com/wp-cli/config-command

Generates and reads the wp-config.php file.

  Sources   Download

MIT

The Requires

 

The Development Requires

19/04 2018

dev-force-library-version-121

dev-force-library-version-121 https://github.com/wp-cli/config-command

Generates and reads the wp-config.php file.

  Sources   Download

MIT

The Requires

 

The Development Requires

12/04 2018

dev-fix-53-php-memory

dev-fix-53-php-memory https://github.com/wp-cli/config-command

Generates and reads the wp-config.php file.

  Sources   Download

MIT

The Requires

 

The Development Requires

30/01 2018

v1.1.8

1.1.8.0 https://github.com/wp-cli/config-command

Generates and reads the wp-config.php file.

  Sources   Download

MIT

The Requires

 

The Development Requires

30/01 2018

dev-handle-old-syntax-gracefully

dev-handle-old-syntax-gracefully https://github.com/wp-cli/config-command

Generates and reads the wp-config.php file.

  Sources   Download

MIT

The Requires

 

The Development Requires

29/01 2018

dev-add-config-modifications

dev-add-config-modifications https://github.com/wp-cli/config-command

Generates and reads the wp-config.php file.

  Sources   Download

MIT

The Requires

 

The Development Requires

08/12 2017

v1.1.7

1.1.7.0 https://github.com/wp-cli/config-command

Manage the wp-config.php file.

  Sources   Download

MIT

The Development Requires

05/12 2017

dev-issue/doc-verbs

dev-issue/doc-verbs https://github.com/wp-cli/config-command

Manage the wp-config.php file.

  Sources   Download

MIT

The Development Requires

20/11 2017

v1.1.6

1.1.6.0 https://github.com/wp-cli/config-command

Manage the wp-config.php file.

  Sources   Download

MIT

The Development Requires

29/09 2017

v1.1.5

1.1.5.0 https://github.com/wp-cli/config-command

Manage the wp-config.php file.

  Sources   Download

MIT

The Development Requires

05/08 2017

v1.1.4

1.1.4.0 https://github.com/wp-cli/config-command

Manage the wp-config.php file.

  Sources   Download

MIT

The Development Requires

06/07 2017

v1.1.3

1.1.3.0 https://github.com/wp-cli/config-command

Manage the wp-config.php file.

  Sources   Download

MIT

The Development Requires

20/06 2017

v1.1.2

1.1.2.0 https://github.com/wp-cli/config-command

Manage the wp-config.php file.

  Sources   Download

MIT

The Development Requires

30/05 2017

v1.1.1

1.1.1.0 https://github.com/wp-cli/config-command

Manage the wp-config.php file.

  Sources   Download

MIT

The Development Requires

04/05 2017

v1.1.0

1.1.0.0 https://github.com/wp-cli/config-command

Manage the wp-config.php file.

  Sources   Download

MIT

The Development Requires

07/04 2017

v1.0.0

1.0.0.0 https://github.com/wp-cli/config-command

Manage the wp-config.php file.

  Sources   Download

MIT

The Development Requires