Download the PHP package curology/envloader without Composer
On this page you can find all versions of the php package curology/envloader. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download curology/envloader
More information about curology/envloader
Files in curology/envloader
Package envloader
Short Description Loads values from AWS Parameter store and uses them to generate a .env file
License MIT
Informations about the package envloader
envloader
Loads parameters from AWS SSM Parameter Store and uses them to generate a dotenv file.
Installation
You can install envloader via composer:
Usage
Configuration
Before you can use the envloader, you must create a json config file. By default, envloader will look for a file named envloader.json
.
Example envloader.json
:
The config file should contain the following entries:
Name | Type | Required | Default | Description |
---|---|---|---|---|
awsProfile | String | No | default | The AWS profile from your ~/.aws/config file that you wish to use. Alternatively, you can set the envloader-specific AWS environment variables AWS_SSM_ACCESS_KEY_ID and AWS_SSM_SECRET_ACCESS_KEY . If both the awsProfile and environment variables are unspecified, envloader will fall back to AWS's environment variables or default profile. The order of precedence is:
|
awsRegion | String | Yes | - | The AWS region that you would like fetch parameters from. |
environment | String | No | default | The name of the environment that the generated dotenv file will be associated with. |
envPath | String | No | .env | The relative path to the file where the generated dotenv file will be written. |
envOverridePath | String | No | - | The relative path to the file containing the override values. Overrides will take precedence over parameters with the same name in AWS. You can also add values to the override file that do not appear in AWS and they will be added to the generated dotenv file. |
workingDir | String | No | getcwd() |
The working directory. envPath and envOverridePath are relative paths from the working directory. |
parameterPrefix | String | No | - | The prefix to the names of your parameters in AWS. |
parameterList | Array | Yes | - | The list of parameter names you would like to fetch from AWS. The parameter names should be in the form NAME:VERSION . If you provided a parameterPrefix , it should be removed form the beginning of the names in the parameterList . |
Run
To list the commands available:
If you do not specify a path to your config file in the commands below, envloader will use envloader.json
.
To generate your dotenv file:
To print the key, value pairs in your dotenv file in a formatted table:
Remove the --with-values
option to hide the parameter values.
Testing
Setup
Install Composer Dependencies
Create AWS Resources
To enable tests that require real data, set the ENVLOADER_TEST_ENABLE_AWS
environment variable to true
:
If this variable is not set, the data-dependent tests will be skipped and you will not have to create any AWS resources.
To run all the tests, you will need real data in AWS SSM Parameter Store, and the required permissions to create the data.
The following instructions use the AWS CLI (version 2.0.46
and above) - you can install it here.
You can alternatively create the parameters via the AWS console UI.
-
Create a user that will have permissions to edit and view the parameters
-
Create an access key for the user. Keep track of the
AccessKeyId
andSecretAccessKey
in the response. -
Add the
AccessKeyId
andSecretAccessKey
from the response to your~/.aws/credentials
file, along with your aws region: -
Grant the user permissions to the SSM Parameters you will create.
Opentests/command/setup/iam_policy.json
and replaceREGION
andACCOUNT_ID
with the aws region and account ID where you will be creating the parameters. -
Create the SSM Parameters.
- The command tests use
us-east-1
as the AWS region. You will have to changetests/fixtures/config/test_envloader_config.json
to include the correct AWS region should you decide to use a different region.
Run
Unit Tests
Command Tests
All Tests
Cleanup
If you want to destroy the AWS resources created for testing, run the following commands:
-
Delete the parameters.
-
Delete the user policy
-
Delete the access key. Replace
AccessKeyId
with the value from your~/.aws/config
- Delete the user
All versions of envloader with dependencies
vlucas/phpdotenv Version ^5.2
php Version ^8.0
symfony/console Version ^5.2