Environment
Environment Configuration
All of the configuration files for the Atom framework are stored in the config
directory.
Environment Configuration
In a fresh Atom installation, the config directory of your application will contain a env.example.json
file. You should rename the file to env.json
. That file contains your application environment configuration.
Your env.json
file should not be committed to your application's source control, since each developer / server using your application could require a different environment configuration. Furthermore, this would be a security risk in the event an intruder gains access to your source control repository, since any sensitive credentials would get exposed.
If you are developing with a team, you may wish to continue including a env.example.json
file with your application. By putting placeholder values in the example configuration file, other developers on your team can clearly see which environment variables are needed to run your application.
Retrieving Environment Configuration
You may use the env
helper to retrieve values from variables in your configuration files. In fact, if you review the Atom configuration files, you will notice several of the options already using this helper:
Notice that if the recovered value is a configuration variable, an configuration object will be returned. For example if you got this configuration file:
env('app_name')
will return string "My Application"; but env('database')
will return an configuration object. You'll get this:
With this, you can access variables of the configuration object like properties. Notice the $database->user
.
You can get all environment configurations with:
Adding Environment Variable
You can add environment configuration with:
Dernière mise à jour
Cet article vous a-t-il été utile ?