New WP-cli issue
newtlabs opened this issue · comments
Hi, now that new features have been added to master I'm having issues when trying to activate something via wp-cli, I have also tried adding --env= to the command but no avail.
Errors:
PHP Notice: Undefined variable: argv in /wp-config.load.php on line 23
PHP Warning: Invalid argument supplied for foreach() in /wp-config.load.php on line 23
PHP Notice: Undefined index: HTTP_HOST in /wp-config.load.php on line 42
PHP Fatal error: Uncaught Exception: Cannot determine current environment via WP_ENV or hostname in /wp-config.load.php:46
Stack trace:
#0 /wp-config.load.php(122): s24_load_environment_config()
#1 phar:///usr/local/bin/wp/php/WP_CLI/Runner.php(964) : eval()'d code(14): require_once('/var/www/h...')
#2 phar:///usr/local/bin/wp/php/WP_CLI/Runner.php(964): eval()
#3 phar:///usr/local/bin/wp/php/WP_CLI/Runner.php(927): WP_CLI\Runner->load_wordpress()
#4 phar:///usr/local/bin/wp/php/WP_CLI/Bootstrap/LaunchRunner.php(23): WP_CLI\Runner->start()
#5 phar:///usr/local/bin/wp/php/bootstrap.php(75): WP_CLI\Bootstrap\LaunchRunner->process(Object(WP_CLI\Bootstrap\BootstrapState))
#6 phar:///usr/local/bin/wp/php/wp-cli.php(23): WP_CLI\bootstrap()
#7 phar:///usr/local/bin/wp/php/boot-phar.php(8): include('phar:///usr/loc...')
#8 /usr/local/bin/wp(4): include('phar:///usr/loc...')
#9 {main}
thrown in /wp-config.load.php on line 46
If you're on Unix, I would recommend to set WP_ENV via environment variable and avoid using --env
, it never worked for me (I haven't tried it with current master though).
Either specify WP_ENV
explicitly for a single command:
$ WP_ENV=development <your-wp-cli-command>
Or set WP_ENV
for entire terminal session:
$ export WP_ENV=development
$ <your-wp-cli-command>
$ <another-wp-cli-command>
yeah i tried that also, cheers. This is on the current master, before changes were merged in it worked ok.
Any updates on this issue ? :( really would like to use this but, I'm dependent on WP-CLI
No updates as of yet, I am also dependant on WP-CLI and am eagerly awaiting some help with this. It may be worth reverting to the previous version until this important issue is fixed...
Hi @newtlabs / @etiennejcharles ,
I've had a quick look at this, and found a fix which is working for me locally.
I've created a branch and submitted a pull request (#25), until that has been reviewed and merged in though, you should be able to manually copy the fix for any of your local projects using this diff:
https://github.com/studio24/wordpress-multi-env-config/pull/25/files
As previously stated, you'll either need to set the environment variable for your machine like so:
export WP_ENV=development
(preferrably this would go in your .bash_profile
so that you don't need to run this every time you open a new terminal window/tab).
Passing env
to the CLI should also work (although I've not tested this as I have the environment variable setup on my machine):
wp plugin list --env="development"
@sean-dunwoody - Good job on the fix, although, I use browsersync to develop, meaning my domain can be multiple values, in the case where I have the domain as an array it doesnt work.
May I suggest the following to your fix ? If theres an array of values, to return the first value?
Any chance of taking another look at this? Am snowed under with 50 WP sites to look after and being able to use WP-CLI would be a massive help.
OK, have merged in Sean's fix for this issue and tested on a WP project that wasn't working under WP CLI. Now works fine.
Will leave the array fixes for now. Will move that request into a new GitHub issue.
Simon
Actually, on review, I will add support for the array domains. Forgot that was supported in this tool.