PHPackages                             wierk/envpress - 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. wierk/envpress

ActiveLibrary

wierk/envpress
==============

A PHP package streamlining the configuration of modern and secure WordPress instances using environment variables.

v0.1.0(2y ago)1626[1 PRs](https://github.com/wierklu/envpress/pulls)MITPHPPHP ^8.1.0

Since May 2Pushed 6mo ago2 watchersCompare

[ Source](https://github.com/wierklu/envpress)[ Packagist](https://packagist.org/packages/wierk/envpress)[ RSS](/packages/wierk-envpress/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (3)Used By (0)

EnvPress
========

[](#envpress)

A PHP package streamlining the configuration of modern and secure WordPress instances using a standard set of environment variables.

Key Features
------------

[](#key-features)

- Designed for [Composer](https://getcomposer.org/) based WordPress setups (e.g. [Bedrock](https://roots.io/bedrock/))
- Static wp-config.php
- Load environment variables from .env files with [vlucas/phpdotenv](https://github.com/vlucas/phpdotenv)
- Gather facts from trusted proxies (e.g. Load Balancers)
- Attach [backing services](https://www.12factor.net/backing-services) using URLs (e.g. MySQL, SMTP)
- Configure [Multisite Networks](https://wordpress.org/documentation/article/create-a-network/) using environment variables
- Apply role and capability changes based on env vars
- Disable native WordPress features using flags (e.g. XML-RPC, comments, oEmbed)
- Harden WordPress by default: Disable file modifications and hide version

Motivation
----------

[](#motivation)

The standard setup of WordPress involves maintaining a wp-config.php file for setting basic configuration options, such as paths, the database connection, and security salts. Except for the actual configuration values, the source code of this file is repeated for each instance with little to no variation. Other common configurations, such as SMTP server credentials and disabling XML-RPC, must be handled separately, far away from wp-config.php, in a custom (child) theme or using multiple third-party plugins.

This package is designed to simplify the configuration process and lessen the maintenance workload for the majority of WordPress instances. It relies on a standard set of environment variables (see list below), rather than boilerplate PHP code, to configure an instance.

Getting Started
---------------

[](#getting-started)

1. Setup Composer based WordPress project:

    The easiest way to do so, is [creating a new Bedrock project](https://roots.io/bedrock/docs/installation/) using Composer:

    ```
    composer create-project roots/bedrock
    ```
2. Install this package via Composer:

    ```
    composer require wierk/envpress
    ```
3. Set up environment variables:

    Configure environment variables in the web server or PHP config (recommended for production) or, alternatively, add them to a file named .env in the root of the project (common for development).

    Minimal set of environment variables to run a WordPress instance:

    ```
    WP_HOME      = https://example.com
    WP_SITEURL   = https://example.com/wp
    DATABASE_URL = mysql://username:password@hostname:port/database
    ```

    Set of env vars providing WordPress salts:

    ```
    SALT_AUTH_KEY         = put your unique phrase here
    SALT_SECURE_AUTH_KEY  = put your unique phrase here
    SALT_LOGGED_IN_KEY    = put your unique phrase here
    SALT_NONCE_KEY        = put your unique phrase here
    SALT_AUTH_SALT        = put your unique phrase here
    SALT_SECURE_AUTH_SALT = put your unique phrase here
    SALT_LOGGED_IN_SALT   = put your unique phrase here
    SALT_NONCE_SALT       = put your unique phrase here
    ```
4. Replace the content of wp-config.php with the following:

    ```
