Title: PHP dotenv in WordPress anyone?
Last modified: August 21, 2016

---

# PHP dotenv in WordPress anyone?

 *  Resolved [growdigital](https://wordpress.org/support/users/growdigital/)
 * (@growdigital)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/php-dotenv-in-wordpress-anyone/)
 * I’d like to use [PHP dotenv](https://github.com/vlucas/phpdotenv) 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](https://wordpress.org/support/users/growdigital/)
 * (@growdigital)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/php-dotenv-in-wordpress-anyone/#post-5046203)
 * 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](http://roots.io/using-composer-with-wordpress/) to manage
   dependencies, hence link to `autoload.php`
 *  Thread Starter [growdigital](https://wordpress.org/support/users/growdigital/)
 * (@growdigital)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/php-dotenv-in-wordpress-anyone/#post-5046390)
 * 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.

## Tags

 * [environment](https://wordpress.org/support/topic-tag/environment/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [variables](https://wordpress.org/support/topic-tag/variables/)

 * In: [Everything else WordPress](https://wordpress.org/support/forum/miscellaneous/)
 * 2 replies
 * 1 participant
 * Last reply from: [growdigital](https://wordpress.org/support/users/growdigital/)
 * Last activity: [11 years, 11 months ago](https://wordpress.org/support/topic/php-dotenv-in-wordpress-anyone/#post-5046390)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
