Download the PHP package wierk/envpress without Composer
On this page you can find all versions of the php package wierk/envpress. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wierk/envpress
More information about wierk/envpress
Files in wierk/envpress
Package envpress
Short Description A PHP package streamlining the configuration of modern and secure WordPress instances using environment variables.
License MIT
Informations about the package envpress
EnvPress
A PHP package streamlining the configuration of modern and secure WordPress instances using a standard set of environment variables.
Key Features
- Designed for Composer based WordPress setups (e.g. Bedrock)
- Static wp-config.php
- Load environment variables from .env files with vlucas/phpdotenv
- Gather facts from trusted proxies (e.g. Load Balancers)
- Attach backing services using URLs (e.g. MySQL, SMTP)
- Configure Multisite Networks 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
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
-
Setup Composer based WordPress project:
The easiest way to do so, is creating a new Bedrock project using Composer:
-
Install this package via Composer:
-
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:
Set of env vars providing WordPress salts:
-
Replace the content of wp-config.php with the following:
Starting from the Bedrock boilerplate, the root config directory may now be removed.
Environment Variables
EnvPress sets up a WordPress instance using a collection of environment variables, listed in the following table. In cases where an environment variable is absent, the corresponding default value is used. These default values are selected to closely resemble a standard, unmodified WordPress installation to avoid unintentional changes. Env vars prefixed APP_
are explicitly reserved for the underlying application and will never be used by this package.
Environment variable | Comments | Default |
---|---|---|
WP_HOME |
URL the WordPress instance can be reached at | Required |
WP_SITEURL |
URL where WordPress core files reside | Required |
WP_ENVIRONMENT_TYPE |
Environment type | production |
WP_DEBUG |
Flag to enable the reporting of some errors or warnings | false |
WP_CACHE |
Flag to enable advanced-cache.php | false |
WP_CRON |
Flag to enable WP Cron based on page load | true |
WP_FILE_MODS |
Flag to enable plugin and theme installation/update | true |
WP_DEFAULT_THEME |
Default WordPress theme name | WordPress default |
WP_POST_REVISIONS |
Number of post revisions (-1, 0, 1, 2, …) | -1 |
WP_ALLOW_REPAIR |
Flag to enable automatic database repair support | false |
WP_ROLES_PATCH |
JSON-encoded set of role and capability changes | No changes |
MULTISITE_ALLOW |
Flag to allow a multisite network | false |
MULTISITE_ENABLE |
Flag to enable a multisite network, once installed | false |
MULTISITE_TYPE |
Either subdomains or subdirectories |
subdirectories |
MULTISITE_DOMAIN |
Value of DOMAIN_CURRENT_SITE |
Required for MS |
MULTISITE_PATH |
Value of PATH_CURRENT_SITE |
Required for MS |
DATABASE_URL |
MySQL server URL (see below) | Required |
DATABASE_CHARSET |
Database character set | utf8mb4 |
DATABASE_COLLATE |
Database collation | Empty |
DATABASE_PREFIX |
Database table prefix | wp_ |
MAILER_FROM_ADDRESS |
Sender email address (may be set in MAILER_URL ) |
WordPress default |
MAILER_FROM_NAME |
Sender name | WordPress default |
MAILER_URL |
SMTP server URL for outgoing mail (see below) | WordPress default |
FEATURE_COMMENTS |
Enable comments and related features | true |
FEATURE_EMOJI |
Enable support for emojis in older browsers | true |
FEATURE_OEMBED |
Enable oEmbed and related features | true |
FEATURE_XMLRPC |
Enable XML-RPC (incl. pingbacks) | true |
SALT_AUTH_KEY |
Cryptographically strong and random key | put your uni… |
SALT_SECURE_AUTH_KEY |
Cryptographically strong and random key | put your uni… |
SALT_LOGGED_IN_KEY |
Cryptographically strong and random key | put your uni… |
SALT_NONCE_KEY |
Cryptographically strong and random key | put your uni… |
SALT_AUTH_SALT |
Cryptographically strong and random key | put your uni… |
SALT_SECURE_AUTH_SALT |
Cryptographically strong and random key | put your uni… |
SALT_LOGGED_IN_SALT |
Cryptographically strong and random key | put your uni… |
SALT_NONCE_SALT |
Cryptographically strong and random key | put your uni… |
ADMIN_SUPPORT_NAME |
Support contact name | Empty |
ADMIN_SUPPORT_URL |
Support contact website URL | Empty |
ADMIN_DASHBOARD_DISABLE |
CSV of dashboard widget ids to be disabled | Empty |
ADMIN_DISPLAY_ENV |
Flag to display the environment type in admin | false |
TRACKING_FATHOM |
Fathom Analytics Site id | Empty |
TRACKING_GTM |
Google Tag Manager Container id | Empty |
PLUGIN_ACF_PRO_LICENSE |
License key for ACF PRO | Empty (disabled) |
RELEASE_VERSION |
Display version of the release | Empty |
RELEASE_URL |
Website URL of the release | Empty |
ENVPRESS_TRUSTED_PROXIES |
CSV of trusted proxy addresses | Empty (disabled) |
Connect Backing Services via URLs
Backing services such as databases, caching systems, or SMTP servers are attached using URLs. These URLs consolidate all the essential connection details, like host name, port, access credentials, and other relevant parameters, into a singular, manageable string.
In URLs, if a user name or password contains special characters ($&+,/:;=?@
), they must be URL encoded.
Database URL/DSN
Query parameters:
ssl-mode
- If set toREQUIRED
, requires an encrypted connection and fails, if one cannot be established.
Mailer URL
Query parameters:
encryption
- Define the encryption to use on the SMTP connection:tls
(default) orssl
.from
- If present, force the from email address to a specified one, overwritingMAILER_FROM_ADDRESS
.
Patching Roles and Capabilities
The WP_ROLES_PATCH
environment variable allows role and capability changes to be defined using a JSON-encoded structure. Each top-level key is a role name, and each value describes changes for that role. Patches are applied only once per unique configuration using an internal hash.
Supported role object attributes:
display_name
- Optional display name used when creating a new role (see add_role)add_cap
- Capability or array of capabilities to add and grant (see WP_Role::add_cap)remove_cap
- Capability or array of capabilities to remove (see WP_Role::remove_cap)deny_cap
- Capability or array of capabilities to add and explicitly deny (relevant for multi-role users)remove_role
- Set totrue
to delete the role entirely (see remove_role)
Example:
This adds the capabilities create_users
and list_users
to the editor
role, removes delete_users
, and deletes the unused
role.
Credits
Created and maintained by Wierk and contributors. Released under the MIT license.