Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

How to set Database connection in Laravel?

user-image
Question added by Julfkar Moh Umar , Sr. Software Engineer , Aakash Edutech Private Limited
Date Posted: 2017/09/28
Murtaza Khokhawala
by Murtaza Khokhawala , I.T. Head of Department , Royal Group of Companies

Find .env file under your project directory

 

DB_DATABASE=attendance_system DB_USERNAME=muzai DB_PASSWORD=xxxx

 

Abid Khan
by Abid Khan , Software Engineer(PHP Laravel) , Intellisense-tech

For connecting your app with DB in laravel you have to configure .env file in your project.

like for MySQL:

DB_CONNECTION=mysql

DB_HOST=127.0.0.1

DB_PORT=3306

DB_DATABASE=xyz

DB_USERNAME=root

DB_PASSWORD=

Lanka Senanayaka
by Lanka Senanayaka , Senior Software Engineer , Ensiz former Fullstack Labs

For laravel 5 use .env file

DB_CONNECTION=mysqlDB_HOST=127.0.0.1DB_PORT=3306DB_DATABASE=mydbDB_USERNAME=myuserDB_PASSWORD=mypass

update fields according to my connection

AHMAD ATHAMNEH
by AHMAD ATHAMNEH , Senior Back-end Engineer & Angular developer & DBA , Edzance

told me first laravel 5 or 4 ??

Arun Raj G S
by Arun Raj G S , CRM Administrator & PHP Developer , ME Group

Use DotENV file. You have all the options there

Julfkar  Moh Umar
by Julfkar Moh Umar , Sr. Software Engineer , Aakash Edutech Private Limited

Database configuration file path is : config/database.php

'mysql' => [

'read' => [ 'host' => 'localhost', ], 'write' => [ 'host' => 'localhost' ], 'driver' => 'mysql', 'database' => 'database', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', ],

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.