Skip to content

Create wp config get to list configuration defined in parsed wp-config.php #2

@danielbachhuber

Description

@danielbachhuber

As a WordPress developer, it would be helpful to have a wp config get command to list configuration defined in parsed wp-config.php

This command could contain both constants and PHP global variables defined in wp-config.php. We can take a similar approach to WP_CLI\Runner in identifying this data:

// Load wp-config.php code, in the global scope
$wp_cli_original_defined_vars = get_defined_vars();
eval( $this->get_wp_config_code() );
foreach( get_defined_vars() as $key => $var ) {
	if ( array_key_exists( $key, $wp_cli_original_defined_vars ) || 'wp_cli_original_defined_vars' === $key ) {
		continue;
	}
	global $$key;
	$$key = $var;
}

Previously wp-cli/wp-cli#3831

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions