1
- isDocker := $( shell docker info > /dev/null 2>&1 && echo 1)
2
- isContainerRunning := $(shell docker ps | grep symfony-php > /dev/null 2>&1 && echo 1)
1
+ containerName = "symfony-php"
2
+ isContainerRunning := $(shell docker info > /dev/null 2>&1 && docker ps | grep $( containerName ) > /dev/null 2>&1 && echo 1)
3
3
user := $(shell id -u)
4
4
group := $(shell id -g)
5
5
6
- ifeq ($(isDocker ) , 1)
7
- ifeq ($(isContainerRunning), 1)
8
- DOCKER_COMPOSE := USER_ID=$(user) GROUP_ID=$(group) docker-compose
9
- DOCKER_EXEC := docker exec -u $(user):$(group) symfony-php
10
- dr := $(DOCKER_COMPOSE) run --rm
11
- sf := $(DOCKER_EXEC) php bin/console
12
- drtest := $(DOCKER_COMPOSE) -f docker-compose.test.yml run --rm
13
- php := $(DOCKER_EXEC) php
14
- else
15
- DOCKER_COMPOSE := USER_ID=$(user) GROUP_ID=$(group) docker-compose
16
- DOCKER_EXEC :=
17
- sf := php bin/console
18
- php :=
19
- endif
20
- else
21
- DOCKER_EXEC :=
22
- sf := php bin/console
23
- php :=
24
- endif
6
+ DOCKER :=
7
+ DOCKER_COMPOSE := USER_ID=$(user ) GROUP_ID=$(group ) docker-compose
8
+ DOCKER_TEST := APP_ENV=test
9
+
10
+ CONSOLE := $(DOCKER ) php
11
+ CONSOLE_MEMORY := $(DOCKER ) php -d memory_limit=256M
12
+ CONSOLE_TEST := $(DOCKER_TEST ) php
13
+ COMPOSER = $(DOCKER ) composer
25
14
26
- COMPOSER = $(DOCKER_EXEC ) composer
27
- CONSOLE = $(DOCKER_COMPOSE ) php bin/console
15
+ ifeq ($(isContainerRunning ) , 1)
16
+ DOCKER := @docker exec -t -u $(user):$(group) $(containerName)
17
+ DOCKER_COMPOSE := USER_ID=$(user) GROUP_ID=$(group) docker-compose
18
+ DOCKER_TEST := @docker exec -t -u $(user):$(group) $(containerName) APP_ENV=test
19
+ endif
28
20
29
21
# # —— App ————————————————————————————————————————————————————————————————
30
22
build-docker :
@@ -41,72 +33,93 @@ stop:
41
33
$(DOCKER_COMPOSE ) stop
42
34
$(DOCKER_COMPOSE ) ps
43
35
44
- restore-permissions :
45
- @echo " Restoring permissions..."
46
- sudo chown -R $(user ) :$(group ) .
36
+ prune :
37
+ @docker-compose down --remove-orphans
38
+ @docker-compose down --volumes
39
+ @docker-compose rm -f
40
+
41
+ serve :
42
+ $(CONSOLE ) serve
43
+
44
+ install-project : install reset-database generate-jwt # # First installation for setup the project
45
+
46
+ update-project : install reset-database # # update the project after a checkout on another branch or to reset the state of the project
47
+
48
+ sync : update-project test-all # # Synchronize the project with the current branch, install composer dependencies, drop DB and run all migrations, fixtures and all test
47
49
48
50
# # —— 🐝 The Symfony Makefile 🐝 ———————————————————————————————————
49
51
help : # # Outputs this help screen
50
52
@grep -E ' (^[a-zA-Z0-9_-]+:.*?## .*$$)|(^## )' Makefile | awk ' BEGIN {FS = ":.*?## "}{printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | sed -e ' s/\[32m##/[33m/'
51
53
52
54
# # —— Composer 🧙♂️ ————————————————————————————————————————————————————————————
53
- composer- install : composer.lock # # Install vendors according to the current composer.lock file
55
+ install : composer.lock # # Install vendors according to the current composer.lock file
54
56
$(COMPOSER ) install -n
55
57
56
- composer- update : composer.json # # Update vendors according to the composer.json file
58
+ update : composer.json # # Update vendors according to the composer.json file
57
59
$(COMPOSER ) update -w
58
60
59
61
# # —— Symfony ————————————————————————————————————————————————————————————————
60
62
cc : # # Apply cache clear
61
- $(DOCKER_EXEC ) sh -c " rm -rf var/cache/*"
62
- $(sf ) cache:clear
63
- $(DOCKER_EXEC ) sh -c " chmod -R 777 var/cache"
63
+ $(DOCKER ) sh -c " rm -rf var/cache"
64
+ $(CONSOLE ) cache:clear
65
+ $(DOCKER ) sh -c " chmod -R 777 var/cache"
66
+
67
+ cc-test : # # Apply cache clear
68
+ $(DOCKER ) sh -c " rm -rf var/cache"
69
+ $(CONSOLE_TEST ) cache:clear
70
+ $(DOCKER ) sh -c " chmod -R 777 var/cache"
64
71
65
72
doctrine-validate :
66
- $(sf ) doctrine:schema:validate --skip-sync $c
73
+ $(CONSOLE ) doctrine:schema:validate --skip-sync $c
67
74
68
75
reset-database : drop-database database migrate load-fixtures # # Reset database with migration
69
76
70
77
database : # # Create database if no exists
71
- $(sf ) doctrine:database:create --if-not-exists
78
+ $(CONSOLE ) migrate:status
72
79
73
80
drop-database : # # Drop the database
74
- $(sf ) doctrine:database:drop --force --if-exists
81
+ $(CONSOLE ) doctrine:database:drop --force --if-exists
75
82
76
83
migration : # # Apply doctrine migration
77
- $(sf ) make:migration
84
+ $(CONSOLE ) make:migration
78
85
79
86
migrate : # # Apply doctrine migrate
80
- $(sf ) doctrine:migration:migrate -n --all-or-nothing
81
-
82
- load-fixtures : # # Load fixtures
83
- $(sf ) doctrine:fixtures:load -n
87
+ $(CONSOLE ) doctrine:migration:migrate -n --all-or-nothing
84
88
85
- generate-jwt :
86
- $(sf ) lexik:jwt:generate-keypair --overwrite -q $c
89
+ generate-jwt : # # Generate private and public keys
90
+ $(CONSOLE ) lexik:jwt:generate-keypair --overwrite -q $c
87
91
88
92
# # —— Tests ✅ ————————————————————————————————————————————————————————————
89
- test-load-fixtures : # # load database schema & fixtures
90
- $(DOCKER_COMPOSE ) sh -c " APP_ENV=test php bin/console doctrine:database:drop --if-exists --force"
91
- $(DOCKER_COMPOSE ) sh -c " APP_ENV=test php bin/console doctrine:database:create --if-not-exists"
92
- $(DOCKER_COMPOSE ) sh -c " APP_ENV=test php bin/console doctrine:migration:migrate -n --all-or-nothing"
93
- $(DOCKER_COMPOSE ) sh -c " APP_ENV=test php bin/console doctrine:fixtures:load -n"
93
+ test-database : # ## load database schema
94
+ $(CONSOLE_TEST ) doctrine:database:drop --if-exists --force
95
+ $(CONSOLE_TEST ) doctrine:database:create --if-not-exists
96
+ $(CONSOLE_TEST ) doctrine:migration:migrate -n --all-or-nothing
97
+ $(CONSOLE_TEST ) doctrine :fixtures:load -n
98
+
99
+ pest :
100
+ $(CONSOLE ) ./vendor/bin/pest
94
101
95
102
test : phpunit.xml* # # Launch main functional and unit tests, stopped on failure
96
- $(php ) APP_ENV=test ./vendor/bin/simple-phpunit
103
+ $(CONSOLE ) ./vendor/bin/pest --stop-on-failure $c
97
104
98
105
test-all : phpunit.xml* test-load-fixtures # # Launch main functional and unit tests
99
- $(php ) APP_ENV=test ./vendor/bin/simple-phpunit
106
+ $(DOCKER_TEST ) ./vendor/bin/pest
100
107
101
- test-report : phpunit.xml* test-load-fixtures # # Launch main functionnal and unit tests with report
102
- $(php ) APP_ENV=test ./vendor/bin/simple-phpunit --coverage-text --coverage-clover=coverage .xml
108
+ test-report : phpunit.xml* test-load-fixtures # # Launch main functional and unit tests with report
109
+ $(DOCKER_TEST ) ./vendor/bin/pest --coverage-text --colors=never --log-junit report .xml $c
103
110
104
111
# # —— Coding standards ✨ ——————————————————————————————————————————————————————
105
112
stan : # # Run PHPStan only
106
- $(php ) ./vendor/bin/phpstan analyse -l 9 src --no-progress -c phpstan.neon --memory-limit 256M
113
+ $(CONSOLE ) ./vendor/bin/phpstan analyse -l 9 src --no-progress -c phpstan.neon --memory-limit 256M
114
+
115
+ ecs : # # Run ECS only
116
+ $(CONSOLE ) ./vendor/bin/ecs check --memory-limit 256M
117
+
118
+ ecs-fix : # # Run php-cs-fixer and fix the code.
119
+ $(CONSOLE ) ./vendor/bin/ecs check --fix --memory-limit 256M
107
120
108
121
cs-fix : # # Run php-cs-fixer and fix the code.
109
- $(php ) ./vendor/bin/php-cs-fixer fix --allow-risky=yes
122
+ $(CONSOLE ) ./vendor/bin/php-cs-fixer fix --allow-risky=yes
110
123
111
124
cs-dry : # # Dry php-cs-fixer and display code may to be change
112
- $(php ) ./vendor/bin/php-cs-fixer fix --dry-run --allow-risky=yes
125
+ $(CONSOLE ) ./vendor/bin/php-cs-fixer fix --dry-run --allow-risky=yes
0 commit comments