0

WP-CLI is doing fine on my Ubuntu server until I am using any server variable in the wp-config.php file.

As soon as I using this:

define('WPMU_PLUGIN_URL', 'https://'. $_SERVER['HTTP_HOST'] .'/must-use-plugins');

or this:

$filepath = $_SERVER['SCRIPT_URI'];

I am getting this:

root@server001:~# wp --allow-root plugin list --path=/var/www/html

PHP Notice:  Undefined index: HTTP_HOST in phar:///usr/bin/wp/php/WP_CLI/Runner.php(792) : eval()'d code on line 42

or this

root@server001:~# wp --allow-root plugin list --path=/var/www/html

PHP Notice:  Undefined index: SCRIPT_URI in phar:///usr/bin/wp/php/WP_CLI/Runner.php(792) : eval()'d code on line 42

However I am not getting this error while running this same command from inside the folder where WordPress is installed.

Please note that this is an automation environment and puppet server is used to deploy the instances, so declaring any variable's value or hard-coding won't do any good in this case.

In short How do I make WP-CLI recognise PHP server variables?

1

You would need to define the global URL parameter in wp-cli.yml or in the command like --url=https://example.com

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.