• Resolved growdigital

    (@growdigital)


    I’d like to use PHP dotenv with WordPress, so that I can easily keep my environment variables out of version control.

    Has anyone had any joy with this? Pretty sure it’s straightforward setting environment variables in PHP but not really my area of expertise.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter growdigital

    (@growdigital)

    This is what I’m putting in wp-config.php:

    require 'vendor/autoload.php';
    Dotenv::load(__DIR__);

    and then:

    define('DB_NAME', 'getenv('DB_NAME')');

    I’m using Composer to manage dependencies, hence link to autoload.php

    Thread Starter growdigital

    (@growdigital)

    Ahh, I had a syntax error, should be:

    define('DB_NAME', getenv('DB_NAME'));

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘PHP dotenv in WordPress anyone?’ is closed to new replies.