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!

Are your smart devices spying on you? Make better purchasing choices and find products that respect your privacy at Unwanted.cloud

RSS Latest posts from my personal blog


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

Full-stack impostor syndrome sufferer & Software Engineer at Schibsted Media Group

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 :)