Skip to content

Instantly share code, notes, and snippets.

@putheakhem
Last active June 20, 2019 01:19
Show Gist options
  • Select an option

  • Save putheakhem/97872dbb706f2727bd433a8f68bba69f to your computer and use it in GitHub Desktop.

Select an option

Save putheakhem/97872dbb706f2727bd433a8f68bba69f to your computer and use it in GitHub Desktop.

Laravel 5.8 : Config, ENV, Migrations, and Todos CRUD

What you will learn ?

  • How to configure .ENV File

.ENV File

Before creating migrations, We will need to setup our database, assuming you know how to create a database using phpmyadmin or MySQL Console. After creating the database, we will add the database credentials in our application. Laravel has a .env environment file which will have all the sensitive data like database details, mail driver details, etc because it’s not recommended to store such information directly inside the code (environment files are not limited to PHP. They are used in all other major frameworks). Values inside the .env files are loaded inside the files from the config directory. .env file is located at the root of our application. Let’s take a look at the file env file.

APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=databaseName 
DB_USERNAME=databaseUsername
DB_PASSWORD=databasePassword

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

Note: Whenever you making changes to .env file then don’t forget to restart the server ( if you are using laravel dev server) and if you are using a virtual host and changes don’t seem to take effect then just run php artisan config:clear (This command will clear the configuration cache) in your terminal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment