DEV Community

Lam Hoang
Lam Hoang

Posted on

1

Laravel Cheat Sheet - Database

Configuring database

The database connection parameters are stored inside .env file (on development environment).

On production environment store it in VirtualHost configuration or .htaccess file. To store variables in .htaccess file VirtualHost must contain the AllowOverride All directive.

Reading environment variable

$value = env('DB_HOST', '127.0.0.1');

Where first value is the name of the variable, and second is the default value (if env variable is not defined).

Connecting to the database server

Using phpMyAdmin

Visit http://localhost/phpmyadmin if you are using XAMPP

Source: Laravel Cheat Sheet

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay