ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

How to set Database connection in Laravel?

user-image
تم إضافة السؤال من قبل Julfkar Moh Umar , Sr. Software Engineer , Aakash Edutech Private Limited
تاريخ النشر: 2017/09/28
Murtaza Khokhawala
من قبل 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
من قبل 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
من قبل 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
من قبل AHMAD ATHAMNEH , Senior Back-end Engineer & Angular developer & DBA , Edzance

told me first laravel 5 or 4 ??

Arun Raj G S
من قبل Arun Raj G S , CRM Administrator & PHP Developer , ME Group

Use DotENV file. You have all the options there

Julfkar  Moh Umar
من قبل 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' => '', ],

المزيد من الأسئلة المماثلة