WP_CLI

Runner::get_project_config_path()publicWP-CLI 1.0

Get the path to the project-specific configuration YAML file. wp-cli.local.yml takes priority over wp-cli.yml.

Method of the class: Runner{}

No Hooks.

Return

String|false.

Usage

$Runner = new Runner();
$Runner->get_project_config_path();

Runner::get_project_config_path() code WP-CLI 2.8.0-alpha

public function get_project_config_path() {
	$config_files = [
		'wp-cli.local.yml',
		'wp-cli.yml',
	];

	// Stop looking upward when we find we have emerged from a subdirectory
	// installation into a parent installation
	$project_config_path = Utils\find_file_upward(
		$config_files,
		getcwd(),
		static function ( $dir ) {
			static $wp_load_count = 0;
			$wp_load_path         = $dir . DIRECTORY_SEPARATOR . 'wp-load.php';
			if ( file_exists( $wp_load_path ) ) {
				++ $wp_load_count;
			}
			return $wp_load_count > 1;
		}
	);

	$this->project_config_path_debug = 'No project config found';

	if ( ! empty( $project_config_path ) ) {
		$this->project_config_path_debug = 'Using project config: ' . $project_config_path;
	}

	return $project_config_path;
}