PHPackages                             wp-cli/config-command - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. wp-cli/config-command

ActiveWp-cli-package[CLI &amp; Console](/categories/cli)

wp-cli/config-command
=====================

Generates and reads the wp-config.php file.

v2.5.0(2mo ago)399.7M↑37.5%38[5 issues](https://github.com/wp-cli/config-command/issues)[2 PRs](https://github.com/wp-cli/config-command/pulls)11MITGherkinCI passing

Since Apr 7Pushed 1mo ago6 watchersCompare

[ Source](https://github.com/wp-cli/config-command)[ Packagist](https://packagist.org/packages/wp-cli/config-command)[ Docs](https://github.com/wp-cli/config-command)[ RSS](/packages/wp-cli-config-command/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (8)Versions (46)Used By (11)

wp-cli/config-command
=====================

[](#wp-cliconfig-command)

Generates and reads the wp-config.php file.

[![Testing](https://github.com/wp-cli/config-command/actions/workflows/testing.yml/badge.svg)](https://github.com/wp-cli/config-command/actions/workflows/testing.yml) [![Code Coverage](https://camo.githubusercontent.com/dfa00196b407b328a1da0dd43efad4f82bf0d1f6ca71642561b9547082063aec/68747470733a2f2f636f6465636f762e696f2f67682f77702d636c692f636f6e6669672d636f6d6d616e642f6272616e63682f6d61696e2f67726170682f62616467652e737667)](https://codecov.io/gh/wp-cli/config-command/tree/main)

Quick links: [Using](#using) | [Installing](#installing) | [Contributing](#contributing) | [Support](#support)

Using
-----

[](#using)

This package implements the following commands:

### wp config

[](#wp-config)

Generates and reads the wp-config.php file.

```
wp config

```

**EXAMPLES**

```
# 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_

# Add a new constant to the wp-config.php file.
$ wp config add WP_DEBUG true --raw
Success: Added the constant 'WP_DEBUG' to the 'wp-config.php' file with the raw value 'true'.

# Update or add a constant to the wp-config.php file.
$ wp config update WP_DEBUG false --raw
Success: Updated the constant 'WP_DEBUG' in the 'wp-config.php' file with the raw value 'false'.

# 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 add

[](#wp-config-add)

Adds a new constant or variable to the wp-config.php file.

```
wp config add   [--raw] [--anchor=] [--placement=] [--separator=] [--type=] [--config-file=]

```

**OPTIONS**

```

	Name of the wp-config.php constant or variable.

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

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

[--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=]
	Where to place the new values in relation to the anchor string.
	---
	default: 'before'
	options:
	  - before
	  - after
	---

[--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 of the config value to add. Defaults to 'constant'.
	---
	default: constant
	options:
	  - constant
	  - variable
	---

[--config-file=]
	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**

```
# Add the WP_DEBUG constant to the wp-config.php file.
$ wp config add WP_DEBUG true --raw
Success: Added the constant 'WP_DEBUG' to the 'wp-config.php' file with the raw value 'true'.

```

### wp config edit

[](#wp-config-edit)

Launches system editor to edit the wp-config.php file.

```
wp config edit [--config-file=]

```

**OPTIONS**

```
[--config-file=]
	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**

```
# 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

[](#wp-config-delete)

Deletes a specific constant or variable from the wp-config.php file.

```
wp config delete  [--type=] [--config-file=]

```

**OPTIONS**

```

	Name of the wp-config.php constant or variable.

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

[--config-file=]
	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**

```
# 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

[](#wp-config-create)

Generates a wp-config.php file.

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

```

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

**OPTIONS**

```
--dbname=
	Set the database name.

--dbuser=
	Set the database user.

[--dbpass=]
	Set the database user password.
	---
	sensitive: true
	---

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

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

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

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

[--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=]
	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.

[--ssl]
	Use SSL when checking the database connection.

```

**EXAMPLES**

```
# 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 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
