Atom Framework
Go to Github
v1.0.0
v1.0.0
  • Installation
  • Getting Started
  • Configuration
    • Environment
    • Authentication
  • Basics
    • Routing
    • Middleware
    • Controllers
    • Models
    • Requests
    • Views
    • URL Generation
    • Session
  • Misc
    • Security
      • Encryption
      • Hashing
    • Storage
    • Moment
Propulsé par GitBook

© 2025 Licon Corp

Sur cette page
  • Environment Configuration
  • Retrieving Environment Configuration
  • Adding Environment Variable

Cet article vous a-t-il été utile ?

  1. Configuration

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:

$app_name = env('app_name');

Notice that if the recovered value is a configuration variable, an configuration object will be returned. For example if you got this configuration file:

{
    "app_name": "My Application",
    "database": {
        "host": "localhost",
        "port": "3306",
        "db_name": "my_db",
        "user": "root",
        "password": ""
    }
}

env('app_name') will return string "My Application"; but env('database') will return an configuration object. You'll get this:

$database = env('database');
$db_user = $database->user;

With this, you can access variables of the configuration object like properties. Notice the $database->user.

You can get all environment configurations with:

$configurations = env()->config();

Adding Environment Variable

You can add environment configuration with:

env()->put('key', 'value');
PrécédentGetting StartedSuivantAuthentication

Dernière mise à jour il y a 6 ans

Cet article vous a-t-il été utile ?