PHPackages                             wearerequired/composer-wp-config - 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. wearerequired/composer-wp-config

ActiveComposer-plugin[Utility &amp; Helpers](/categories/utility)

wearerequired/composer-wp-config
================================

A composer plugin to create the WordPress configuration file which automagically defines constants from a .env file. Also includes path of Composer's autoloader in wp-config.php.

1.1.1(10mo ago)920.8k↑28.6%2[2 issues](https://github.com/wearerequired/composer-wp-config/issues)[4 PRs](https://github.com/wearerequired/composer-wp-config/pulls)MITPHPPHP &gt;=7.4CI passing

Since Feb 21Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/wearerequired/composer-wp-config)[ Packagist](https://packagist.org/packages/wearerequired/composer-wp-config)[ RSS](/packages/wearerequired-composer-wp-config/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (7)Versions (22)Used By (0)

composer-wp-config
==================

[](#composer-wp-config)

[![Latest Stable Version](https://camo.githubusercontent.com/b36e65a1e7f1d968763c66500343c2a396c2c66b4b145cc89736743edc7fa866/68747470733a2f2f706f7365722e707567782e6f72672f776561726572657175697265642f636f6d706f7365722d77702d636f6e6669672f762f737461626c65)](https://packagist.org/packages/wearerequired/composer-wp-config)[![Latest Unstable Version](https://camo.githubusercontent.com/c86c52448180ed97d4a27a0e4c4c2140be84a6ffcf72c6b57faa6801a2c067a7/68747470733a2f2f706f7365722e707567782e6f72672f776561726572657175697265642f636f6d706f7365722d77702d636f6e6669672f762f756e737461626c65)](https://packagist.org/packages/wearerequired/composer-wp-config)

A plugin for Composer to create the WordPress configuration file which automagically defines constants from a .env file. Also includes path of Composer's autoloader in wp-config.php.

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

[](#installation)

Via Composer

```
composer require johnpbloch/wordpress wearerequired/composer-wp-config

```

Copy [`.env.example`](res/.env.example) and save it as `.env`. By default the variables are searched in a `.env` file in the same directory as `wp-config.php` .

### List of required variables

[](#list-of-required-variables)

- `_HTTP_HOST` (Used when `$_SERVER['SERVER_NAME']` is not set, like WP-CLI.)
- `DB_NAME`
- `DB_USER`
- `DB_PASSWORD`
- `AUTH_KEY`
- `SECURE_AUTH_KEY`
- `LOGGED_IN_KEY`
- `NONCE_KEY`
- `AUTH_SALT`
- `SECURE_AUTH_SALT`
- `LOGGED_IN_SALT`
- `NONCE_SALT`

See also the list of [default constants](#default-constants).

### Customize path to .env file

[](#customize-path-to-env-file)

You can override the path(s) with the following extra in your `composer.json`:

```
{
    "extra": {
        "wp-config-env-paths": [
            "../",
            "../configs"
        ]
    }
}
```

Note that the path must be relative to the `wp-config.php` file. Run `composer build-wp-config` to rebuild the `wp-config.php` file.

Features
--------

[](#features)

- Creates `wp-config.php` one level above the WordPress installation.
- The `wp-config.php` includes the path to Composer's autoloader.
- Searches for `.env` file with the help of [PHP dotenv](https://github.com/vlucas/phpdotenv).
- Defines all variables as constants unless a constant is already set.
- Defines reasonable default values for database, object cache, debug, URL, and path constants.
- Use `{{DIR}}` as placeholder in variable values to get it replaced with `__DIR__` of `wp-config.php`.
- Supports `URL_DEVELOPMENT`, `URL_STAGING`, and `URL_PRODUCTION` for [WordPress Stage Switcher](https://github.com/roots/wp-stage-switcher). Requires at least v2.1.
- Supports loading `wp-config-prepend.php` before and `wp-config-append.php` after the default config as part of `wp-config.php`.
- Loads the WordPress plugin API early so actions and filters can be used.

Default Constants
-----------------

[](#default-constants)

If the following variables are not defined they will be assigned a default value:

Variable nameDefault value`WP_ENV``'development'``WP_ENVIRONMENT_TYPE`Value of `WP_ENV``QM_DISABLED``true``SAVEQUERIES``false``WP_DEBUG``false``WP_DISABLE_FATAL_ERROR_HANDLER`Value of `WP_DEBUG``WP_DEBUG_LOG``false``WP_DEBUG_DISPLAY``false``SCRIPT_DEBUG``false``DISALLOW_FILE_MODS``true``DB_HOST``'localhost'``DB_CHARSET``'utf8'``DB_COLLATE``''``$table_prefix``'wp_'``WP_CACHE_KEY_SALT`Value of `WP_ENV``WP_HOME`Based on `$_SERVER['SERVER_NAME']`/`_HTTP_HOST` and `$_SERVER['HTTPS']``WP_SITEURL`Value of `WP_HOME``WP_CONTENT_FOLDER_NAME``'content'``WP_CONTENT_DIR``__DIR__ . '/' . WP_CONTENT_FOLDER_NAME``WP_CONTENT_URL``WP_HOME . '/' . WP_CONTENT_FOLDER_NAME`Planned Features
----------------

[](#planned-features)

- Allow to change required variables via `composer.json`.
- Allow to change variables not used as a constant via `composer.json`.
- Let us know what you think is missing…

[![a required open source product - let's get in touch](https://camo.githubusercontent.com/47e05f68aa9692e2185b9c29cb810dcd02ea3546c00fb25e0152a343154b76bf/68747470733a2f2f6d656469612e72657175697265642e636f6d2f696d616765732f6f70656e2d736f757263652d62616e6e65722e706e67)](https://required.com/en/lets-get-in-touch/)

###  Health Score

48

—

FairBetter than 93% of packages

Maintenance64

Regular maintenance activity

Popularity33

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 83.3% 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 ~143 days

Recently: every ~212 days

Total

15

Last Release

321d ago

Major Versions

0.9.0 → 1.0.02024-03-26

PHP version history (2 changes)0.1.0PHP &gt;=7.1

0.5.0PHP &gt;=7.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1446895?v=4)[required](/maintainers/wearerequired)[@wearerequired](https://github.com/wearerequired)

---

Top Contributors

[![ocean90](https://avatars.githubusercontent.com/u/617637?v=4)](https://github.com/ocean90 "ocean90 (80 commits)")[![grappler](https://avatars.githubusercontent.com/u/1785641?v=4)](https://github.com/grappler "grappler (8 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (6 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (2 commits)")

---

Tags

composercomposer-pluginconfigurationdotenvphpwordpresswordpressconfigautoloadenvdotenvwpwp-config

### Embed Badge

![Health badge](/badges/wearerequired-composer-wp-config/health.svg)

```
[![Health](https://phpackages.com/badges/wearerequired-composer-wp-config/health.svg)](https://phpackages.com/packages/wearerequired-composer-wp-config)
```

###  Alternatives

[roots/bedrock

WordPress boilerplate with Composer, easier configuration, and an improved folder structure

6.5k463.8k2](/packages/roots-bedrock)[ffraenz/private-composer-installer

A composer install helper for private packages

2321.7M5](/packages/ffraenz-private-composer-installer)[philippbaschke/acf-pro-installer

An install helper for Advanced Custom Fields PRO

283724.6k](/packages/philippbaschke-acf-pro-installer)[wecodemore/wpstarter

Composer plugin to easily build WordPress websites entirely managed via Composer.

254208.3k10](/packages/wecodemore-wpstarter)

PHPackages © 2026

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