Image for post
Image for post

In order to connect a database, we will concentrate on the .env file. This is where you will find the configuration settings to set the database host, username and password along with a host of configurations. You may never end up using all of them. Below is an example of the .env file that is generated when you create a new Laravel project.

APP_NAME=LaravelAPP_ENV=localAPP_KEY=base64:7b6e1+2Ok25kR2g54fVFeEWfXciimtt5eAvBSK7RpWc=APP_DEBUG=trueAPP_URL=http://localhostLOG_CHANNEL=stackDB_CONNECTION=mysqlDB_HOST=127.0.0.1DB_PORT=3306DB_DATABASE=homesteadDB_USERNAME=homesteadDB_PASSWORD=secretBROADCAST_DRIVER=logCACHE_DRIVER=fileQUEUE_CONNECTION=syncSESSION_DRIVER=fileSESSION_LIFETIME=120REDIS_HOST=127.0.0.1REDIS_PASSWORD=nullREDIS_PORT=6379MAIL_DRIVER=smtpMAIL_HOST=smtp.mailtrap.ioMAIL_PORT=2525MAIL_USERNAME=nullMAIL_PASSWORD=nullMAIL_ENCRYPTION=nullPUSHER_APP_ID=PUSHER_APP_KEY=PUSHER_APP_SECRET=PUSHER_APP_CLUSTER=mt1MIX_PUSHER_APP_KEY=”${PUSHER_APP_KEY}”MIX_PUSHER_APP_CLUSTER=”${PUSHER_APP_CLUSTER}”…

About

Mohammad Javed

Front End Web Developer - Developing in WordPress, Magento, Shopify, Umbraco & Laravel.

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store