Laravel comes with many stunning features. One of them is definitely database migrations. In the next chapter we’ll discuss about migration in detail.
Before that we need to understand our environment properly. What is environment in Laravel? If you look at the document root you will find an ‘.env’ file. It basically says about the database connections. Where would we get that default database set up file? In the ‘config’ folder, we have a ‘database.php’ file. Open it up and see the content.
We see a line that tells us about the default database connection.
'default' => env('DB_CONNECTION', 'mysql'),
It’s MySQL. We’re not going to change it for now although it’s temporary. Because in the later part of the book we’ll see how we can work with SQLite database. At present just keep it as it is – our default database is MySQL. Now opening up our ‘.env’ file we add our database, username and password.
There is a glitch of course. Suppose we’d like to place our project in any cloud repository like ‘github’. In that case, our secrets may come out.
Laravel has thought about it.
In the ‘.gitignore’ file it has already added this line:
When you place the whole project it’ll automatically ignore the listed folders and files. Homestead.yaml and Homestead.json are among them.
We’ve set up our environment and now we can safely move to our next big chapter database migrations. After that we’ll discuss Eloquent and after that we’ll finally see how Model, view and controller workflow work. We’ll also see how we can ‘create, retrieve, update and delete’ our SQLite database.