1+ # Executables (local)
2+ DOCKER_COMP = docker compose
3+
4+ # Docker containers
5+ PHP_CONT = $(DOCKER_COMP ) exec -e COMPOSER_MEMORY_LIMIT=-1 php
6+
7+ # Executables
8+ PHP = $(PHP_CONT ) php -d memory_limit=-1
9+ COMPOSER = $(PHP_CONT ) composer
10+ SYMFONY = $(PHP ) bin/console
11+ PHPUNIT = $(PHP ) bin/phpunit
12+
13+ # Misc
14+ .DEFAULT_GOAL = help
15+ .PHONY : help build up start down logs sh composer vendor sf cc
16+
17+ # # —— 🎵 🐳 The Symfony Docker Makefile 🐳 🎵 ——————————————————————————————————
18+ help : # # Outputs this help screen
19+ @grep -E ' (^[a-zA-Z0-9\./_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST ) | awk ' BEGIN {FS = ":.*?## "}{printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | sed -e ' s/\[32m##/[33m/'
20+
21+ # # —— Docker 🐳 ————————————————————————————————————————————————————————————————
22+ build : # # Builds the Docker images
23+ @$(DOCKER_COMP ) -f docker-compose.yml -f docker-compose.dev.yml build # --pull --no-cache
24+
25+ up : # # Start the docker hub in detached mode (no logs)
26+ @$(DOCKER_COMP ) -f docker-compose.yml -f docker-compose.dev.yml up --detach
27+
28+ up-build : # # Start the docker hub in detached mode (no logs)
29+ @$(DOCKER_COMP ) -f docker-compose.yml -f docker-compose.dev.yml up --build --detach
30+
31+ up-prod : # # Start the docker hub in detached mode (no logs)
32+ @$(DOCKER_COMP ) -f docker-compose.yml -f docker-compose.prod.yml up --detach
33+
34+ up-prod-build : # # Start the docker hub in detached mode (no logs)
35+ @$(DOCKER_COMP ) -f docker-compose.yml -f docker-compose.prod.yml up --build --detach
36+
37+ start : build up # # Build and start the containers
38+
39+ stop : # # Stop the docker hub
40+ @$(DOCKER_COMP ) stop
41+
42+ down : # # Stop the docker hub
43+ @$(DOCKER_COMP ) down --remove-orphans
44+
45+ logs : # # Show live logs
46+ @$(DOCKER_COMP ) logs --tail=0 --follow
47+
48+ sh : # # Connect to the PHP FPM container
49+ @$(PHP_CONT ) sh
50+
51+ perms : # # Connect to the PHP FPM container
52+ @$(PHP_CONT ) chown www-data ./var/cache -R
53+ @$(PHP_CONT ) chmod 0777 ./var/cache -R
54+
55+ remove-cache : # # Connect to the PHP FPM container
56+ @$(PHP_CONT ) rm -rf ./var/cache/dev
57+ @$(PHP_CONT ) rm -rf ./var/cache/prod
58+
59+ # # —— Composer 🧙 ——————————————————————————————————————————————————————————————
60+ composer : # # Run composer, pass the parameter "c=" to run a given command, example: make composer c='req symfony/orm-pack'
61+ @$(eval c ?=)
62+ @$(COMPOSER ) $(c )
63+
64+ vendor : # # Install vendors according to the current composer.lock file
65+ vendor : c=install --prefer-dist --no-dev --no-progress --no-scripts --no-interaction
66+ vendor : composer
67+
68+ # # —— Symfony 🎵 ———————————————————————————————————————————————————————————————
69+ phpunit : # # List all Symfony commands or pass the parameter "c=" to run a given command, example: make sf c=about
70+ @$(PHPUNIT )
71+
72+ # # —— Symfony 🎵 ———————————————————————————————————————————————————————————————
73+ sf : # # List all Symfony commands or pass the parameter "c=" to run a given command, example: make sf c=about
74+ @$(eval c ?=)
75+ @$(SYMFONY ) $(c )
76+
77+ cc : c=c:c # # Clear the cache
78+ cc : sf
0 commit comments