Follow the following link for instructions to install docker on Mac
Download and install the symfony binary
Follow the instructions at https://symfony.com/download
Set up the application
Create a symfony application
Create a sample todo application using symfony new command
symfony new todo
This will create a minimal web application using symfony.
Change into the project directory
You can start the symfony web server using
symfony serve -d
You can see the application by issuing
Now, this application does not have a database configured yet.
You can see the database configuration in the .env file.
Setting up symfony server with docker database service
Symfony server integrates well with docker
We have to create a database service in docker-compose.yaml. Refer to https://hub.docker.com/_/mysql to create a mysql database service.
The integration documentation for symfony server and docker can be found at https://symfony.com/doc/current/setup/symfony_server.html#docker-integration
After bringing up the database service using docker-compose up -d, Symfony server will now connect to the database service in the docker-compose file.
To check run
symfony console doctrine:database:create
This will create the default database configured using doctrine configuration.
This will mean though, that you have to use
The above command will work through the conjuration for DATABASE_URL in .env configuration.
To make the app work in both cases, make sure the DATABASE_URL is also configured properly.
This is an easy setup for any local development using symfony.
Another option is to use symfony server as a docker service.
For that, you will have to define an app service , where you put the steps to create the symfony project in the Dockerfile and then give symfony serve command as the docker-compose service command, without the -d option, so the service will run in the foreground.
To further ease the process, use a Makefile to prepare the project and run the docker-compose commands.0