In order to work with the database in Symfony, we will be using Doctrine, an open source library which is focused on database storage and object mapping.
Configuration for doctrine package is located in config/packages/doctrine.yaml file. You can leave that as is, as the defaults are fine and you can work with those without a problem. If you want to check what those properties mean, please refer here
Everything here is self explanatory, you should change user, password and database. We still did not create a new database, so, in the next step, we will create a new database with the name you specified in the connection string.
This will connect to your database server, authenticate with username and password you specified and create a new database with the database name you specified.
This will install the necessary bundle that will allow us to run migrations. The migrations will be stored in src/Migrations .There are 3 commands that you need to know:
This will generate an empty migration class. Generating empty migrations is useful when you want to add seed data, data that should be applied to all instances of the databases over multiple environments. Example of this data is if you have a table which defines types that will be constant and should have the same Ids over all instances.
This will generate a new migration, but will add only differences between your current code and the database structure. This is done in order to update your database with the new structure that you create in Entities PHP Classes.
This will execute all migrations that have not been executed. DoctrineMigrationsBundle creates a table in your database where it will keep track of all the migrations that were executed. So, when you execute this command, it will take that table into account and will execute migrations that are not there, but present as PHP Classes in src/Migrations folder.
In the second part we will be creating our first entity.