Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

How to set Database connection in Laravel?

user-image
Question ajoutée par Julfkar Moh Umar , Sr. Software Engineer , Aakash Edutech Private Limited
Date de publication: 2017/09/28
Murtaza Khokhawala
par 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
par 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
par 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
par AHMAD ATHAMNEH , Senior Back-end Engineer & Angular developer & DBA , Edzance

told me first laravel 5 or 4 ??

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

Use DotENV file. You have all the options there

Julfkar  Moh Umar
par 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