PHPackages                             scottjs/wp-dotenv - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. scottjs/wp-dotenv

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

scottjs/wp-dotenv
=================

Helper scripts to enable WordPress to use dotenv config files, similar to Laravel 5.

1.1.0(9y ago)1811.7k3[1 issues](https://github.com/scottjs/wp-dotenv/issues)1MITPHP

Since Apr 2Pushed 9y ago1 watchersCompare

[ Source](https://github.com/scottjs/wp-dotenv)[ Packagist](https://packagist.org/packages/scottjs/wp-dotenv)[ RSS](/packages/scottjs-wp-dotenv/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (16)Used By (1)

WP Dotenv
=========

[](#wp-dotenv)

Inspired by Laravel 5, WP Dotenv enables WordPress to use .env files for its configuration instead of wp-config.php. This is useful if you're planning on using [scottjs/db-sync](https://github.com/scottjs/db-sync) or [scottjs/helper-scripts](https://github.com/scottjs/helper-scripts) with WordPress.

Requirements
------------

[](#requirements)

- Composer
- PHP &gt;= 5.3.9
- A local development environment, such as Vagrant.

Notes
-----

[](#notes)

- These scripts require a .env config file to be created in the project root, this file will be used to configure WordPress.
- Running this script will replace the existing `wp-config.php` with a modified version to use the .env file.

Installation
------------

[](#installation)

Run `composer require "scottjs/wp-dotenv:1.*"` from the root of your project.

Alternatively, you can manually add `"scottjs/wp-dotenv": "1.*"` to your `composer.json` file:

```
"require": {
	"scottjs/wp-dotenv": "1.*"
},

```

Then add the following scripts to your `composer.json` file:

```
"scripts": {
	"generate-config" : [
		"vendor/scottjs/wp-dotenv/generate-config.sh"
	],
	"generate-config-with-salts" : [
		"vendor/scottjs/wp-dotenv/generate-config.sh salts"
	]
}

```

Run the `composer update` command from the root of your project.

Create a `.env` file in the root of your project and add/update the following configuration options:

```
APP_DOCROOT=
APP_CORE=
APP_DEBUG=false
APP_WWW=false
APP_SSL=false

DB_HOST=localhost
DB_DATABASE=example
DB_USERNAME=root
DB_PASSWORD=password

```

Usage
-----

[](#usage)

From the root of your project, you will be able to run the following composer commands:

- ***composer generate-config*** - This command will generate a modified wp-config.php file to allow WordPress to use the .env file. This requires `APP_DOCROOT` to be set in the .env file.
- ***composer generate-config-with-salts*** - As above, but will also generate the salts automatically. This is a handy command to use when starting a new project, but it can be used at any time.

Config
------

[](#config)

See below for an explanation of each configuration option used within the .env file.

- ***APP\_ENV*** - When set to `local`, the WordPress admin panel will display buttons in the admin panel to upgrade plugins and WordPress files. When set to `production`, the ability to plugins/software through the admin panel is disabled.
- ***APP\_DOCROOT*** - Required by ***composer generate-config***, it should be relative to your project root folder and point to where the document root is configured. It should start with a slash and not include a trailing slash. Leave blank if not applicable. Example: `/public`.
- ***APP\_CORE*** - Required if WP core files are located in a subdirectory relative to `APP_DOCROOT`. It should point to the directory where WP core is installed. It should start with a slash and not include a trailing slash. Leave blank if not applicable. Example: `/wp`.
- ***APP\_DEBUG*** - Allows you to enable or disable WP debugging. Options: `true` or `false`.
- ***APP\_WWW*** - Allows you to force WordPress to redirect to www or non-www web addresses. Options: `true` or `false`.
- ***APP\_SSL*** - Allows you to force WordPress to use the SSL protocol and handle redirection. Options: `true` or `false`.
- ***DB\_***\* - Provides options to set the local database connection details.

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~23 days

Recently: every ~74 days

Total

14

Last Release

3446d ago

Major Versions

0.7.2 → 1.0.02016-04-05

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/994732?v=4)[Scott Salisbury](/maintainers/scottjs)[@scottjs](https://github.com/scottjs)

---

Top Contributors

[![scottjs](https://avatars.githubusercontent.com/u/994732?v=4)](https://github.com/scottjs "scottjs (38 commits)")

### Embed Badge

![Health badge](/badges/scottjs-wp-dotenv/health.svg)

```
[![Health](https://phpackages.com/badges/scottjs-wp-dotenv/health.svg)](https://phpackages.com/packages/scottjs-wp-dotenv)
```

###  Alternatives

[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[lullabot/drainpipe

An automated build tool to allow projects to have a set standardized operations scripts.

43785.5k4](/packages/lullabot-drainpipe)[ec-europa/toolkit

Toolkit packaged for Drupal projects based on Robo.

40252.8k34](/packages/ec-europa-toolkit)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
