0
0
Laravelframework~5 mins

Database configuration in Laravel - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What file in a Laravel project holds the main database configuration settings?
The .env file holds the main database configuration settings like database name, username, password, and host.
Click to reveal answer
beginner
How do you specify the database connection type in Laravel?
You specify the database connection type in the DB_CONNECTION variable inside the .env file, for example, DB_CONNECTION=mysql.
Click to reveal answer
intermediate
Where does Laravel store the default database connection settings besides the .env file?
Laravel stores default database connection settings in the config/database.php file, which reads values from the .env file.
Click to reveal answer
beginner
What is the purpose of the DB_HOST variable in Laravel's database configuration?
The DB_HOST variable defines the address of the database server Laravel should connect to, like 127.0.0.1 or a remote IP.
Click to reveal answer
intermediate
How can you configure multiple database connections in Laravel?
You can add multiple connections inside the connections array in config/database.php and switch between them by setting DB_CONNECTION in .env.
Click to reveal answer
Which file do you edit to set your database username in Laravel?
A.env
Bconfig/app.php
Croutes/web.php
Dpublic/index.php
What does the DB_CONNECTION variable specify?
AThe database port number
BThe database password
CThe type of database to connect to
DThe database host address
Where are the default database connection settings stored in Laravel?
Aconfig/database.php
Bapp/Models
Cresources/views
Dstorage/logs
If you want to connect to a remote database server, which variable do you change?
ADB_USERNAME
BDB_HOST
CDB_CONNECTION
DAPP_URL
How do you switch between multiple database connections in Laravel?
ARestart the server
BEdit <code>routes/web.php</code>
CChange the database password
DChange the <code>DB_CONNECTION</code> value in <code>.env</code>
Explain how Laravel uses the .env file and config/database.php together for database configuration.
Think about where you put your database details and how Laravel reads them.
You got /4 concepts.
    Describe the steps to configure Laravel to connect to a MySQL database on a remote server.
    Focus on the variables in the .env file related to MySQL.
    You got /5 concepts.