Skip to content

wp config create would benefit from clear path to defer all parameter initialization. #124

Closed

Description

@JollyWizard

It would seem to me that the optional/required parameters for wp config create are a little overbearing, especially considering the capabilities of wp config set. I don't see a strong reason why all of the parameters shouldn't be optional.

Verification is important, but given the wide variety of environments out there, the host/user only requirement seems very over/under in regards to actually having all the info to verify a connection (I'm assuming the purpose of them being required is to conduct that test).

Given the kitchen sink list of parameters possibly required, and the comparative ease of use of wp config set. It would be nice if there was an official, clearly indicated way to jump over to the for-each usage style.

I would prefer a flag that indicates this intention and skips the checks, but the command documentation could more clearly steer users to this possibility, as well.

I'm sure many users, like myself, are also interested in simplifying the injection of these parameters from the environment variables already present in their Docker container. At that point, you are already for-eaching in a bunch of (possibly missing) parameters, so why not include the other two.

To illustrate my process/point:


If setting up an environment like this:

$ docker run -it --rm wordpress:cli bash

bash-5.1$ wp core download --skip-content

Downloading WordPress 5.7 (en_US)...
md5 hash verified: b3033cdce55dd8c9af9eaed9233475d4
Success: WordPress downloaded.

This use case should have a shorthand flag, i.e. wp config create --template.

bash-5.1$ wp --skip-check config create --dbname= --dbuser=

Success: Generated 'wp-config.php' file.

To support setting all parameters in a for-each style like this (unrolled for clarity):

bash-5.1$ wp config set DB_NAME wordpress
Success: Updated the constant 'DB_NAME' in the 'wp-config.php' file with the value 'wordpress'.
bash-5.1$ wp config set DB_USER root
Success: Updated the constant 'DB_USER' in the 'wp-config.php' file with the value 'root'.
bash-5.1$ wp config set DB_PASSWORD example
Success: Updated the constant 'DB_PASSWORD' in the 'wp-config.php' file with the value 'example'.

Activity

  1. changed the title [-]Create would benefit from clear path to defer all parameter initialization.[/-] [+]`wp config create` would benefit from clear path to defer all parameter initialization.[/+] on Mar 21, 2021
  2. danielbachhuber commented on Nov 10, 2023

    @danielbachhuber
    Member

    Thanks for the suggestion, @JollyWizard !

    I'm open to the idea of making --dbname=<dbname> and --dbuser=<dbuser> optional. This is relevant for SQLite support too (#167). However, if we did so, we'd need to mark it as a breaking change, because there's some rare scenario where a script could be dependent on the current error behavior if dbname or dbuser are missing.

    We're likely to tag a WP-CLI 3.0.0 in the next year (https://github.com/wp-cli/wp-cli/milestone/70), and could include this change in that release.

    Another option (not necessarily a good one) is to introduce a wp config init or similar command that makes a very basic wp-config.php and incorporates different behavior.

    cc @wp-cli/committers if there are other opinions.

  3. schplurtz commented on May 4, 2024

    @schplurtz

    I'd really like to see that in wp 3.0. Whatever the solution used, this would be really useful.

  4. pwtyler commented on Apr 14, 2026

    @pwtyler
    Contributor

    Looks like this was (at least partially) addressed with #219, but perhaps if the optional case is only scoped to sqlite, it may not entirely address the spirit of the original ask.

  5. swissspidy commented on Apr 14, 2026

    @swissspidy
    Member

    I suppose we could remove that SQLite drop-in check entirely to address this fully.

  6. swissspidy commented on Apr 15, 2026

    @swissspidy
    Member

    #223 looks reasonable: make the arguments optional if either SQLite is detected or --skip-check is used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions