Test on macOS Catalina 10.15.7 and macOS Big Sur 10.0.1
If you already have a Symfony project, just copy the docker folder and the docker-compose at the root of your application, and go to "4. Configure .env".
git clone git@github.com:DavidMaarek/docker-base-nginx-php-mariadb-for-symfony.git
cd docker-base-nginx-php-mariadb-for-symfony
Run this if if you are building a traditional web application
composer create-project symfony/website-skeleton symfony_project
Run this if your are buliding a microservice, console application or API
composer create-project symfony/skeleton symfony_project
Run this if if you are building a traditional web application
mv symfony_project/* ./ && mv symfony_project/.* ./
rm -rf symfony_project
In the .env file created by composer, configure the DATABASE_URL
DATABASE_URL=mysql://db_user:db_password@mariadb:3306/db_name?serverVersion=mariadb-10.5.5
And add 4 more variables at the end of the file :
MYSQL_DATABASE=db_name
MYSQL_USER=db_user
MYSQL_PASSWORD=db_password
MYSQL_ROOT_PASSWORD=root_password
By default, it's localhost, but if you want to customize the domain name, go to this file docker/nginx/default.conf
, and at line 5 and change localhost to whatever you want.
And on MacOS edit this file sudo vi /private/etc/hosts
, and add 127.0.0.1 yourCustomDomain
At the root of the project, launch this command :
docker-compose up