PHPackages                             devuri/wp-env-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. devuri/wp-env-config

Abandoned → [devuri/wpframework](/?search=devuri%2Fwpframework)ArchivedLibrary[Utility &amp; Helpers](/categories/utility)

devuri/wp-env-config
====================

A small package to define WordPress configuration constants using environment variables with a .env file.

v3.3.0(2y ago)61.5k2MITPHPPHP ^7.4 || ^8.0

Since Mar 4Pushed 2y ago1 watchersCompare

[ Source](https://github.com/devuri/wp-env-config)[ Packagist](https://packagist.org/packages/devuri/wp-env-config)[ Docs](https://github.com/devuri/wp-env-config)[ RSS](/packages/devuri-wp-env-config/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (10)Dependencies (23)Versions (78)Used By (2)

 [![](https://user-images.githubusercontent.com/4777400/225331174-d5ae1c0e-5ec0-493b-aabc-91c4cc6a14c4.png)](https://user-images.githubusercontent.com/4777400/225331174-d5ae1c0e-5ec0-493b-aabc-91c4cc6a14c4.png)

WordPress Environment Configuration
-----------------------------------

[](#wordpress-environment-configuration)

[![Unit Tests](https://github.com/devuri/wp-env-config/actions/workflows/unit-tests.yml/badge.svg)](https://github.com/devuri/wp-env-config/actions/workflows/unit-tests.yml)

### Introduction

[](#introduction)

`wp-env-config` is a small yet powerful package that simplifies the process of defining configuration constants in WordPress. By leveraging PHP dotenv, this package enables you to securely store sensitive configuration data in environment variables, which is a best practice for building and deploying software according to the twelve-factor app methodology.

> **Note**This repository houses the fundamental components of wp-env-config. If you are developing an application, please utilize wp-env-app located in this repository: [wp-env-app](https://github.com/devuri/wp-env-app).

### Installation

[](#installation)

To use `wp-env-config`, you can install it via Composer. Run the following command in your terminal:

```
composer create-project devuri/wp-env-app blog
```

> or for existing projects

```
composer require devuri/wp-env-config
```

Alternatively, you can add `devuri/wp-env-config` to your project's `composer.json` file:

```
"require": {
    "devuri/wp-env-config": "^0.5"
}
```

Once installed, you can begin using the package in your WordPress project.

```
# This is how the structure might look.

├── .env
├── wp-config.php
├── composer.json
├── composer.lock
├── LICENSE
├── public/
│   ├── index.php
│   ├── wp-admin/
│   ├── wp-content/
│   ├── wp-includes/
│   ├── .htaccess
│   ├── robots.txt
│   └── ...
└── vendor/
```

### Usage

[](#usage)

To get started, create a `.env` file in the root directory of your project. In this file, define the environment variables you wish to use as configuration constants, update the database credentials and other settings as needed.

```
WP_HOME='https://example.com'
WP_SITEURL="${WP_HOME}"

WP_ENVIRONMENT_TYPE='production'
DEVELOPER_ADMIN='0'

MEMORY_LIMIT='256M'
MAX_MEMORY_LIMIT='256M'

DB_NAME=wp_dbName
DB_USER=root
DB_PASSWORD=
DB_HOST=localhost
DB_PREFIX=wp_
```

> Full list of [Environment Variables](https://devuri.github.io/wp-env-config/env/)

Then, in your **wp-config.php** file, add the following code:

```
