Download the PHP package sroze/companienv without Composer
On this page you can find all versions of the php package sroze/companienv. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sroze/companienv
More information about sroze/companienv
Files in sroze/companienv
Informations about the package companienv
Companienv
Your companion for .env
files. Everybody knows about 12 factor and environments variables now.
A lot of frameworks such as Symfony are using a .env
file to configure the application,
but we don't have anything to help users to complete their local .env
file.
Companienv will helps you manage the .env
files, from a reference .env.dist
version in your code repository. Companienv can:
- Read and populate default values
- Identify and ask only missing variables
- Ask variables only if matching some conditions
- Propagate files (copy files from somewhere else)
- Generate public/private RSA keys
- Generate SSL certificates
- Much more, via your own extensions
Usage
-
Require
sroze/companienv
as your project dependency: - Run your companion:
Composer automation
You can run Companienv automatically after composer install
or composer update
commands by configuring the scripts in your composer.json
file:
By default, the file used as a template is .env.dist
and the written file is .env
. You can change these defaults within your composer.json
file:
The .env.dist
file
All your configuration is directly in your .env.dist
file, as comments. The configuration is divided in blocks that
will be displayed to the user for a greater understanding of the configuration. Here are the fondations for Companienv:
- Blocks. They logically group variables together. They are defined by a title (line starting with a double-comment
##
) and a description (every comment line directly bellow) - Attributes. Defined by a line starting with
#+
, an attribute is associated to one or multiple variables. These attributes are the entrypoint for extensions. In the example above, it says that theJWT_*
variables are associated with an RSA key pair, so Companienv will automatically offer the user to generate one for them. - Comments. Lines starting by
#~
will be ignored by Companienv.
Example of .env.dist.
file
Built-in extensions
- Only if ...
- Propagate file
- RSA keys
- SSL certificate
only-if
extension
Some of the blocks of your .env
file might not even be relevant if some other variable was disabling a given feature.
Example: This will only ask for the INTERCOM_APPLICATION_ID
variable if INTERCOM_ENABLED
has the value (current
or entered by the user) true
.
file-to-propagate
extension
Will ask the path of an existing file and copy it to the destination mentioned in the reference.
Example: this will ask the user to give the path of an existing file. It will copy this file to the path
/runtime/keys/firebase.json
, relative to the root directory of the project.
rsa-pair
extension
If the public/private key pair does not exist, Companienv will offer to generate one for the user.
ssl-certificate-extension
Similar to the RSA keys pair: Companienv will offer to generate a self-signed SSL certificate if it does not exist yet.
Your own extensions
You can easily create and use your own extensions with Companienv. In order to do so, you'll have to start Companienv
with your own PHP file and use the registerExtension
method of the Application
:
All versions of companienv with dependencies
symfony/console Version ~3.4 || ~4.0 || ~5.0 || ~6.0
symfony/dotenv Version ~3.4 || ~4.0 || ~5.0 || ~6.0
symfony/process Version ~3.4 || ~4.0 || ~5.0 || ~6.0
jackiedo/dotenv-editor Version ~1.0