Fast lightweight Docker network using PHP MySQL Nginx and Node
docker-compose up -d --build
Go inside the /var/www/project folder:
docker exec -it php74-container bash
Install Symfony project folder with composer:
composer create-project symfony/skeleton .
In your root folder, not in Docker container:
git init
Back in the container:
symfony check:req
Install Doctrine with Composer (orm-pack):
composer require doctrine
Configure MySQL credentials in .env file
uncomment line with DATABASE_URL="mysql:
and comment on line with DATABASE_URL="postgresql:
So we have: DATABASE_URL="mysql://root:secret@mysql8-service:3306/docker-symfony?serverVersion=8"
where:
- login: root
- password: secret
- host: mysql8-service (taken from the Dockerfile)
- port: 3306
- base name: choose what you want
- serverVersion: we use MySQL v8
exit
For info:
You may use docker-compose run
instead of docker exec
docker-compose run --rm php74-service php bin/console doctrine:database:create
Hint: (docker exec for containers and docker-compose for services)
docker exec -it mysql8-container bash
mysql -uroot -psecret
... and YES! NO SPACE after -u and -p options!
show databases;
Then quit MySQL and exit MySQL container:
quit
then:
exit
First, connect to PHP74 container:
docker exec -it php74-container bash
Then install with Composer:
composer require encore
Then exit the container:
exit
docker-compose run --rm node-service yarn install
docker-compose run --rm node-service yarn dev