Useful Snippets

Welcome!


This blog is used to collect useful snippets related to Linux, PHP, MySQL and more. Feel free to post comments with improvements or questions!

RSS Latest posts from my personal blog


Most viewed posts


Subscribe to RSS feed


Simple development / production configuration management in WordPress

Stanislav KhromovStanislav Khromov

I’ve seen a few posts about managing multiple WordPress configuration files in dev / prod environments. (Such as this one.) Many of them seem a bit over-engineered, so why make it more complicated than it has to be? Here is probably the fastest way to setup different configuration files for development and production environments in WordPress:

Snippet:

<?php
/* Config loading based on environment variable */
if(getenv('WP_ENV') === 'dev')
    include 'wp-config.dev.php';
else
    include 'wp-config.prod.php';

Development

SetEnv WP_ENV   dev

Production

SetEnv WP_ENV   prod
PHP

Web Developer at Aftonbladet (Schibsted Media Group)
Any opinions on this blog are my own and do not reflect the views of my employer.
LinkedIn
Twitter
WordPress.org Profile
Visit my other blog

Comments 1
  • JD
    Posted on

    JD JD

    Reply Author

    Awesome post!

    I just started custom developing my own WordPress themes, this is super helpful. Bookmarked :)