Download the PHP package devuri/wp-env-config without Composer
On this page you can find all versions of the php package devuri/wp-env-config. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download devuri/wp-env-config
More information about devuri/wp-env-config
Files in devuri/wp-env-config
Package wp-env-config
Short Description A small package to define WordPress configuration constants using environment variables with a .env file.
License MIT
Homepage https://github.com/devuri/wp-env-config
Informations about the package wp-env-config
WordPress Environment Configuration
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.
Installation
To use wp-env-config
, you can install it via Composer. Run the following command in your terminal:
or for existing projects
Alternatively, you can add devuri/wp-env-config
to your project's composer.json
file:
Once installed, you can begin using the package in your WordPress project.
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.
Full list of Environment Variables
Then, in your wp-config.php file, add the following code:
This will load the environment variables from the .env
file and define them as configuration constants.
You can define as many constants as you need using this approach.
Setup Options and Environment
Environment Constants.
Debug must be on and 'development' set as WP_ENVIRONMENT_TYPE in the .env file.
This will output the following:
Global helper functions.
asset()
The asset() function will generate a URL for an asset.
- We can configure the asset URL by setting the
ASSET_URL
in your .envASSET_URL="${WP_HOME}/assets"
- Or optionally in the main config file.
asset_url()
The asset_url() URL for the asset directory.
- Note: The
ASSET_URL
constant is optional. - We can configure the asset URL by setting the
ASSET_URL
in your .envASSET_URL="${WP_HOME}/assets"
- Or optionally in the main config file.
env()
The env() function can be used to get the value of an environment variable.
Kernel.
Kernel
$args
We can use the Kernel $args
to setup a custom directory structure.
CI/CD
We can use a GitHub Actions workflow to automate the deployment process.
https://github.com/marketplace/actions/ssh-remote-commands
Headless Mode
Corcel Corcel is a collection of PHP classes built on top of Eloquent ORM (from Laravel framework), that provides a fluent interface to connect and get data directly from a WordPress database. https://github.com/corcel/corcel
Headless Mode A helper plugin for putting WordPress in "headless mode". Designed for when WordPress is the CMS for a headless/ decoupled WordPress site.
https://github.com/Shelob9/headless-mode
Redis Object Cache
[!WARNING]
Please note that configuring Redis Object Cache can be a complex process, as it relies on an external Redis server to function properly. If you have little or no experience with setting up Redis servers, or configuring applications that use Redis, it is recommended that you seek assistance or consult with an expert before attempting to use this plugin.
The Redis Object Cache: https://wordpress.org/plugins/redis-cache/ paired with https://github.com/phpredis/phpredis/blob/develop/INSTALL.md will supercharge web application.
- We will need to install and setup the redis server, this varies widely based on your current server setup: https://redis.io/docs/getting-started/
- Install and setup phpredis https://github.com/phpredis/phpredis/blob/develop/INSTALL.md
- Install and configure the plugin: Installing Redis Object Cache: https://github.com/rhubarbgroup/redis-cache/blob/develop/INSTALL.md
Its best to use phpredis we have had issues in the past while testing where the cron jobs start failing, also if you decide to go for Redis Object Cache pro, phpredis is required.
Why
The aim of this package is to simplify the definition of WordPress configuration constants by leveraging PHP dotenv to access environment variables stored in a .env file. By utilizing environment variables in this way, we can enhance the security of our WordPress installation by avoiding the storage of sensitive credentials in our code.
This approach adheres to the twelve-factor app methodology for building and deploying software, specifically principle three, which emphasizes the importance of storing configuration data in the environment. By implementing this package, we can follow this best practice and ensure that our WordPress instance is both secure and maintainable.
Development and Support Status (in-Beta)
⚠️ This project is currently in active development. If you're considering using it for production, please feel free to get in touch, and we'll gladly offer additional guidance and support. We also encourage and welcome any issues and pull requests related to this framework.
We are still in the beta testing phase. While it's actively under development, we are actively seeking user feedback and making improvements. You're welcome to join our Slack community, where we have ongoing and active discussions.
All versions of wp-env-config with dependencies
defuse/php-encryption Version ^2.4
devuri/cpt-meta-box Version ^0.4
devuri/dot-access Version ^0.2.2
devuri/encryption Version ^0.3
devuri/secure-password Version ^0.1
devuri/uuid-generator Version ^0.0.1
filp/whoops Version ^2.15
johnpbloch/wordpress Version ^6.2
symfony/error-handler Version ^5.0
symfony/filesystem Version ^5.4
symfony/var-dumper Version ^5.4
vlucas/phpdotenv Version ^5.2
psr/log Version ^1.1