Skip to content

Commit fdbd2d7

Browse files
Update config commands examples (#174)
* Update config commands examples * Add examples for main class * Regenerate README --------- Co-authored-by: Nilambar Sharma <> Co-authored-by: Daniel Bachhuber <daniel.bachhuber@automattic.com>
1 parent 890b6e3 commit fdbd2d7

2 files changed

Lines changed: 110 additions & 0 deletions

File tree

README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,57 @@ Generates and reads the wp-config.php file.
1919
wp config
2020
~~~
2121

22+
**EXAMPLES**
23+
24+
# Create standard wp-config.php file.
25+
$ wp config create --dbname=testing --dbuser=wp --dbpass=securepswd --locale=ro_RO
26+
Success: Generated 'wp-config.php' file.
27+
28+
# List constants and variables defined in wp-config.php file.
29+
$ wp config list
30+
+------------------+------------------------------------------------------------------+----------+
31+
| key | value | type |
32+
+------------------+------------------------------------------------------------------+----------+
33+
| table_prefix | wp_ | variable |
34+
| DB_NAME | wp_cli_test | constant |
35+
| DB_USER | root | constant |
36+
| DB_PASSWORD | root | constant |
37+
| AUTH_KEY | r6+@shP1yO&$)1gdu.hl[/j;7Zrvmt~o;#WxSsa0mlQOi24j2cR,7i+QM/#7S:o^ | constant |
38+
| SECURE_AUTH_KEY | iO-z!_m--YH$Tx2tf/&V,YW*13Z_HiRLqi)d?$o-tMdY+82pK$`T.NYW~iTLW;xp | constant |
39+
+------------------+------------------------------------------------------------------+----------+
40+
41+
# Get wp-config.php file path.
42+
$ wp config path
43+
/home/person/htdocs/project/wp-config.php
44+
45+
# Get the table_prefix as defined in wp-config.php file.
46+
$ wp config get table_prefix
47+
wp_
48+
49+
# Set the WP_DEBUG constant to true.
50+
$ wp config set WP_DEBUG true --raw
51+
Success: Updated the constant 'WP_DEBUG' in the 'wp-config.php' file with the raw value 'true'.
52+
53+
# Delete the COOKIE_DOMAIN constant from the wp-config.php file.
54+
$ wp config delete COOKIE_DOMAIN
55+
Success: Deleted the constant 'COOKIE_DOMAIN' from the 'wp-config.php' file.
56+
57+
# Launch system editor to edit wp-config.php file.
58+
$ wp config edit
59+
60+
# Check whether the DB_PASSWORD constant exists in the wp-config.php file.
61+
$ wp config has DB_PASSWORD
62+
$ echo $?
63+
0
2264

65+
# Assert if MULTISITE is true.
66+
$ wp config is-true MULTISITE
67+
$ echo $?
68+
0
69+
70+
# Get new salts for your wp-config.php file.
71+
$ wp config shuffle-salts
72+
Success: Shuffled the salt keys.
2373

2474

2575

@@ -78,6 +128,7 @@ wp config delete <name> [--type=<type>] [--config-file=<path>]
78128

79129
# Delete the COOKIE_DOMAIN constant from the wp-config.php file.
80130
$ wp config delete COOKIE_DOMAIN
131+
Success: Deleted the constant 'COOKIE_DOMAIN' from the 'wp-config.php' file.
81132

82133

83134

@@ -437,6 +488,7 @@ wp config set <name> <value> [--add] [--raw] [--anchor=<anchor>] [--placement=<p
437488

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

441493

442494

@@ -471,6 +523,7 @@ wp config shuffle-salts [<keys>...] [--force] [--config-file=<path>] [--insecure
471523

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

475528
## Installing
476529

src/Config_Command.php

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,60 @@
66

77
/**
88
* Generates and reads the wp-config.php file.
9+
*
10+
* ## EXAMPLES
11+
*
12+
* # Create standard wp-config.php file.
13+
* $ wp config create --dbname=testing --dbuser=wp --dbpass=securepswd --locale=ro_RO
14+
* Success: Generated 'wp-config.php' file.
15+
*
16+
* # List constants and variables defined in wp-config.php file.
17+
* $ wp config list
18+
* +------------------+------------------------------------------------------------------+----------+
19+
* | key | value | type |
20+
* +------------------+------------------------------------------------------------------+----------+
21+
* | table_prefix | wp_ | variable |
22+
* | DB_NAME | wp_cli_test | constant |
23+
* | DB_USER | root | constant |
24+
* | DB_PASSWORD | root | constant |
25+
* | AUTH_KEY | r6+@shP1yO&$)1gdu.hl[/j;7Zrvmt~o;#WxSsa0mlQOi24j2cR,7i+QM/#7S:o^ | constant |
26+
* | SECURE_AUTH_KEY | iO-z!_m--YH$Tx2tf/&V,YW*13Z_HiRLqi)d?$o-tMdY+82pK$`T.NYW~iTLW;xp | constant |
27+
* +------------------+------------------------------------------------------------------+----------+
28+
*
29+
* # Get wp-config.php file path.
30+
* $ wp config path
31+
* /home/person/htdocs/project/wp-config.php
32+
*
33+
* # Get the table_prefix as defined in wp-config.php file.
34+
* $ wp config get table_prefix
35+
* wp_
36+
*
37+
* # Set the WP_DEBUG constant to true.
38+
* $ wp config set WP_DEBUG true --raw
39+
* Success: Updated the constant 'WP_DEBUG' in the 'wp-config.php' file with the raw value 'true'.
40+
*
41+
* # Delete the COOKIE_DOMAIN constant from the wp-config.php file.
42+
* $ wp config delete COOKIE_DOMAIN
43+
* Success: Deleted the constant 'COOKIE_DOMAIN' from the 'wp-config.php' file.
44+
*
45+
* # Launch system editor to edit wp-config.php file.
46+
* $ wp config edit
47+
*
48+
* # Check whether the DB_PASSWORD constant exists in the wp-config.php file.
49+
* $ wp config has DB_PASSWORD
50+
* $ echo $?
51+
* 0
52+
*
53+
* # Assert if MULTISITE is true.
54+
* $ wp config is-true MULTISITE
55+
* $ echo $?
56+
* 0
57+
*
58+
* # Get new salts for your wp-config.php file.
59+
* $ wp config shuffle-salts
60+
* Success: Shuffled the salt keys.
61+
*
62+
* @package wp-cli
963
*/
1064
class Config_Command extends WP_CLI_Command {
1165

@@ -582,6 +636,7 @@ private static function get_wp_config_vars( $wp_config_path = '' ) {
582636
*
583637
* # Set the WP_DEBUG constant to true.
584638
* $ wp config set WP_DEBUG true --raw
639+
* Success: Updated the constant 'WP_DEBUG' in the 'wp-config.php' file with the raw value 'true'.
585640
*
586641
* @when before_wp_load
587642
*/
@@ -685,6 +740,7 @@ public function set( $args, $assoc_args ) {
685740
*
686741
* # Delete the COOKIE_DOMAIN constant from the wp-config.php file.
687742
* $ wp config delete COOKIE_DOMAIN
743+
* Success: Deleted the constant 'COOKIE_DOMAIN' from the 'wp-config.php' file.
688744
*
689745
* @when before_wp_load
690746
*/
@@ -815,6 +871,7 @@ public function has( $args, $assoc_args ) {
815871
*
816872
* # Add a cache key salt to the wp-config.php file
817873
* $ wp config shuffle-salts WP_CACHE_KEY_SALT --force
874+
* Success: Shuffled the salt keys.
818875
*
819876
* @subcommand shuffle-salts
820877
* @when before_wp_load

0 commit comments

Comments
 (0)