The .env
file accommodates key-value pairs for configuration settings which will change relying on the setting (e.g., growth, testing, manufacturing). Right here’s an instance of what your .env
file may seem like:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel_db
DB_USERNAME=root
DB_PASSWORD=your_password_here
APP_NAME=Laravel APP_ENV=native APP_KEY=base64:your_app_key_here APP_DEBUG=true APP_URL=http://localhost
DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=laravel_db DB_USERNAME=root DB_PASSWORD=your_password_here |
Every line represents a selected configuration:
APP_NAME: The title of your utility.
APP_ENV: The setting during which the appliance is working (native, manufacturing, and so forth.).
APP_DEBUG: Determines whether or not debugging data is proven (set to true in growth).
APP_URL: The bottom URL of the appliance.
Database settings: Laravel makes use of these settings to hook up with your database
The default .env
file is created robotically once you arrange a brand new Laravel mission, however you possibly can modify it to match your want.
For instance , in case you are utilizing MySQL as your database, make sure the settings replicate your native database configuration
DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=laravel_db DB_USERNAME=root DB_PASSWORD=your_password_here |
Save adjustments and shut the .env
file.
Producing the Software key
Laravel requires an utility key for encryption, which is about within the .env
file underneath APP_KEY. This secret is used to safe cookies, encrypt delicate information and extra.
To generate a brand new utility key, run:
This command generates a random key and updates your .env
file robotically. After working the command, you need to see a line like this in your .env
file:
APP_KEY=base64:generated_key_here |
Loading setting adjustments
Typically, Laravel could not acknowledge adjustments within the .env
file instantly. To make sure adjustments are loaded, clear the configuration cache by working:
NOTE: The .env
file ought to by no means be shared publicly or uploaded to model management (e.g., Github). It include delicate data.