All About Laravel Env File - FreeCodeBlog

Last updated: Nov 09, 2021

Read this tutorial to know all about laravel env file. laravel env file is most important for live server. In this tutorial I will explain you about laravel env file. so this this tutorial slowly to know about laravel env file.

 

Laravel Env File.

Once new laravel have been installed, you will see env file in laravel project root folder. If you didn't see .env file in root folder then copy .env.example file to .env file. You need to install laravel to know about laravel env file. I have a installed laravel. if you don't know to installation laravel then read how to install any kind of laravel version tutorial.

 

cp .env.example .env

 

Laravel App Information In Env File.

You will see app name, app env, app key, app debug, app url in laravel env file. By default, you will see like below. you can easily change app information for production.

 

# local
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:64-bit-key
APP_DEBUG=true

# production
APP_NAME="Masum Biswas"
APP_ENV=production
APP_KEY=base64:64-bit-key
APP_DEBUG=false

 

Please use key generate command to regenerate app key and solve laravel session error.

 

php artisan key:generate

 

Laravel Database Inforamtion In Env File.

You will see MySQL database information in laravel env file. you need to change MySQL database on production. read how to create MySQL database on shared hosting cpanel tutorial to change MySQL database on production.

 

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=

 

Laravel Mail Inforamtion In Env File.

You will see mail information in laravel env file. you need to change mail information on local and production. read how to use laravel mailtrap to send email tutorial to change mail information on local. for shared hosting cpanel mail connection please read laravel mail configuration on shared hosting cpanel tutorial.

 

MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"

 

Thanks.

Post Tags
Post Writer
masum7323
Masum Biswas (@masum7323)

My name is Masum Biswas. I'm a full stack developer. I live in Bangladesh and I love to write tutorials and tools that can help to other artisan. I am a big fan of PHP, Javascript, JQuery, Laravel, MySQL, VueJS, Tailwind CSS and Bootstrap from the early stage.

Follow Me On
Related Posts
Install Tailwind Css In Laravel With Laravel Ui

I will explain you how we can install tailwind css in laravel 8 with laravel ui 3. please read this tutorial slowly to install and setup tailwind c... Read More

Best Cloud Hosting For Laravel Project

Laravel is a widely used and easy open source PHP framework which is used to create complex and simple web applications. It is based on a architect... Read More

Solve Ckeditor 5 Code Block Plugin Not Working In Laravel

Ckeditor 5 code block plugin not working in laravel? No. Do you have a programming laravel project and want to use code block ckeditor 5 plugin in... Read More

Fix Laravel Failed To Authenticate On Smtp Server With Username Mail Error On Cpanel

Still using laravel on cpanel with mail connection? Yes. Did you get it error message like failed to authenticate on smtp server with username on c... Read More

Upgrade Laravel 5.8 To 8 Version Complete Tutorial

Want to upgrade laravel 5.8 to 8 version? Yes. Still using older Laravel versions like laravel 5.7, 5.8 or higher for your website? If you use a ve... Read More