shogun Posted February 26, 2020 Share Posted February 26, 2020 I usually setup ProcessWire locally and my remote server has a different username and password. After completing all testing locally, where can I update the database credentials in the processwire files to match my remote server before pushing files? Link to comment Share on other sites More sharing options...
dragan Posted February 26, 2020 Share Posted February 26, 2020 Just update site/config.php If you want to keep the same config.php locally and remote, add a simple if statement or switch/case if ($_SERVER['SERVER_NAME'] === 'dev.mysite.com') { $config->dbHost = 'foo.mysql.db.host.com'; $config->dbName = 'xxxxx'; $config->dbUser = 'xxxxx'; $config->dbPass = 'xxxxx'; $config->dbPort = '3306'; } 2 Link to comment Share on other sites More sharing options...
shogun Posted March 5, 2020 Author Share Posted March 5, 2020 Perfect, but then where do you go to update the main url in the database? When I uploaded, it's still using the https://localhost url as the root url Link to comment Share on other sites More sharing options...
shogun Posted March 5, 2020 Author Share Posted March 5, 2020 Everything seems ok except this variable is still pointing to localhost for some reason $pages->get(1)->httpUrl Link to comment Share on other sites More sharing options...
dragan Posted March 5, 2020 Share Posted March 5, 2020 1 hour ago, shogun said: where do you go to update the main url in the database Nowhere. PW doesn't store any such thing anywhere. You define allowed hosts in the config, but that's it. This is most probably a caching issue. Try to delete everything inside site/assets/cache/, your browser cache and try again. Link to comment Share on other sites More sharing options...
Mustafa-Online Posted March 5, 2020 Share Posted March 5, 2020 I do it this way: i define a config->local then : /**** Config Enviroment **********/ $config->local = true; if($config->local == true) { $config->debug = false; $config->dbHost = 'localhost'; $config->dbName = 'dbname_on_local'; $config->dbUser = 'user_on_local'; $config->dbPass = '*********'; } else { $config->debug = false; $config->dbHost = 'localhost'; $config->dbName = 'dbname_on_server'; $config->dbUser = 'user_on_server'; $config->dbPass = '***********'; } And just toggle $config->local value between true / false 1 Link to comment Share on other sites More sharing options...
gebeer Posted March 6, 2020 Share Posted March 6, 2020 You can have a site/config-dev.php with all config for your local dev environment. If this file exists, all config values will be pulled from it instead of site/config.php. This is the common PW-way of having separate configs for live and development environments. This info can be found on this page in the docs at the very bottom. 1 Link to comment Share on other sites More sharing options...
hellomoto Posted April 26, 2020 Share Posted April 26, 2020 On 3/5/2020 at 6:02 PM, gebeer said: You can have a site/config-dev.php with all config for your local dev environment. If this file exists, all config values will be pulled from it instead of site/config.php. This is the common PW-way of having separate configs for live and development environments. This info can be found on this page in the docs at the very bottom. I never knew, but I prefer my way: I keep config.php and then will have a config.dev.php and/or config.www.php and require whichever is appropriate via a switch conditional in config.php depending on the hostname. So in config.dev.php debug is true, and both have their respective DB credentials, and any other variations can be specified/distributed very easily and cleanly this way without repetition. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now