bernhard

Maintain separate configs for live/dev like a boss :)

Recommended Posts

Have you ever come across the situation where you needed to change your config.php file for local development? Have you ever come across this warning?

5aaa5dc1bd4d7_2018-03-1512_48_50-EditPage_Homehrd_w4y1.baumrock_com.png.36e7826396df488c67d6a672c7279712.png

Say goodbye to this little annoying tasks :)

Some of you might know that you can have a separate config-dev.php file for local development. This is nice, but also needs some setup (for example excluding this file for git upload) and there is still some danger of uploading this file to a place where it should not be... The other option was to keep the database settings for your live and dev server in sync - also not easy and maybe not the best...

My solution is as simple, fast and I think it should be even safer than the other options. Just put these lines at the end of your config.php file:

if(strpos($config->paths->root, 'C:/laragon/') === 0) {
  $config->dbUser = 'root';
  $config->dbPass = '';
  $config->httpHosts = array($_SERVER[HTTP_HOST]);
  $config->debug = true;
}

Having a separate config-dev.php file also makes it necessary to keep both files in sync. That was my first idea: To include the original config and then overwrite settings. But it's just simpler the other way round: Using the default config.php file and overwriting settings there.

https://github.com/processwire/processwire-requests/issues/169

  • Like 6
  • Thanks 1

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.