How To · PostgreSQL · Symfony 4

Configure Symfony 4 with PostgreSQL on Ubuntu or Mac

How to configure Symfony 4 with PostgreSQL on Ubuntu or Mac OS

Install PostgreSQL on Ubuntu  
Easily install PostgreSQL from the command line with apt-get.

Install PostgreSQL on Mac   
On Mac OS, go to your terminal and use brew as shown here.
Use composer to install Doctrine   
If Doctrine is not already installed, then from the command line in your Symfony 4 project directory, use composer to require doctrine.
Configure config/doctrine.yml
Change the dbal values as shown below.

Edit the .env file.   
PostgreSQL may create a user matching the user you logged in as. You will need to change the db_user and password to whatever is appropriate. Replace the mysql settings with the PostgreSQL settings as shown below:

Now you can use the command line to create the database!

Leave a Reply

Your email address will not be published. Required fields are marked *