welaika / wordmove

Multi-stage command line deploy/mirroring and task runner for Wordpress
https://wptools.it/wordmove
MIT License
1.87k stars 167 forks source link

wp-config.php is not updated with local db settings #356

Closed mvasin closed 7 years ago

mvasin commented 7 years ago

I do wordmove pull -all and get everything succesfully imported from production to local, but have to manually replace production database credentials with local database credentials in wp-config.php.

Is this the way it's supposed to be? Seems to be semi-automated.

alessandro-fazzi commented 7 years ago

Hi there,

actually Wordmove has an exclusion by default inside its Movefile

exclude:
    - [...cut...]
    - "wp-config.php"

So the supposed behaviour is not to push back and forth the wp-config.php file. At first push you will go on production url with the browser, you will do the configuration just this time and you won't need anymore to think about wp-config.php on that server.

If you deleted the exclusion you are loosing a lot of time without any real benefit.

Keep in mind: there are a lot of alternative workflows concerning the wp-config.php file out there. I'm assuming you are approaching with the Wordpress default one. Just to spend a word about an option:

// wp-config.php

// Definitions of DB params are deleted from here

switch ($_SERVER['HTTP_HOST']) {
    case 'localhost':
        include 'wp-config.development.php';
        break;

    case 'example.com':
        include 'wp-config.production.php';
        break;

    defalut:
        die("Can't match current environtment");
}
// wp-config.development.php

define('DB_USER', 'root');
define('DB_PASSWORD', '');
define('DB_HOST', 'localhost');
// wp-config.production.php

define('DB_USER', 'youruser');
define('DB_PASSWORD', 'yourautogeneratedsuperstrongpasswotd');
define('DB_HOST', 'thestrangeaddressthehostinggaveyou');

Well this way - pls, do not copy/paste this code written just as an example - I bet you could also remove the exclusion from the Movefile and manage multiple environments. Sky's the limit for other ideas.

Mark as closed if you feel I've asked someway :)

Cheers

mvasin commented 7 years ago

Thank you! I think I'll take the idea of taking credentials out to evironment variables.