Use Of .env File In Laravel

Use Of .env File In Laravel

Laravel .env file is useful when you have different configuration values based on the environment where the application is running.For example if you want to have different cache driver locally than you do on your production server.

To make this work Laravel utilizes the DotEnv PHP library by Vance Lucas.If you fresh Laravel installation, then root directory of your project will contain a .env.example file.But if you install Laravel via Composer, this file will automatically be renamed to .env. Otherwise, you should rename the file manually.

Always make sure you will add .env file in .gitignore so that it will not be committed to your application's source control.Because your development server and local development might have different configuration.

Define variable in .env file.


Retrieving Environment Configuration


Determining The Current Environment

The current application environment is determined via the APP_ENV variable from your .env file

Categories: PHP Tags: #Laravel,

Newsletter Subcribe

Receive updates and latest news direct from our team. Simply enter your email.