|
| 1 | +# Executables (host) |
| 2 | +DOCKER_COMPOSE = docker compose |
| 3 | + |
| 4 | +# Docker containers |
| 5 | +APP_CONTAINER = $(DOCKER_COMPOSE) exec app |
| 6 | + |
| 7 | +# Executables |
| 8 | +PHP = $(APP_CONTAINER) php |
| 9 | +COMPOSER = $(APP_CONTAINER) composer |
| 10 | + |
| 11 | +# Misc |
| 12 | +.DEFAULT_GOAL = help |
| 13 | + |
| 14 | +## 👷 Makefile |
| 15 | +help: ## Outputs this help screen |
| 16 | + @grep '(^[a-zA-Z0-9_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}{printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | sed 's/\[32m##/[33m/' |
| 17 | + |
| 18 | +## 🐳 Docker |
| 19 | +build: ## Builds the Docker images |
| 20 | + @$(DOCKER_COMPOSE) --progress=plain build --pull --no-cache |
| 21 | + |
| 22 | +up: ## Start the Docker cluster |
| 23 | + @$(DOCKER_COMPOSE) up |
| 24 | + |
| 25 | +start: ## Start the Docker cluster in detached mode (no logs) |
| 26 | + @$(DOCKER_COMPOSE) up --detach |
| 27 | + |
| 28 | +stop: ## Stop the Docker cluster |
| 29 | + @$(DOCKER_COMPOSE) stop |
| 30 | + |
| 31 | +down: ## Stop and remove the Docker cluster |
| 32 | + @$(DOCKER_COMPOSE) down --remove-orphans --volumes |
| 33 | + |
| 34 | +logs: ## Show live logs |
| 35 | + @$(DOCKER_COMPOSE) logs --tail=0 --follow |
| 36 | + |
| 37 | +ps: ## Show containers' statuses |
| 38 | + @$(DOCKER_COMPOSE) ps |
| 39 | + |
| 40 | +sh: ## Connect to the app container |
| 41 | + @$(APP_CONTAINER) sh |
| 42 | + |
| 43 | +php: ## Run PHP on app container, pass the parameter "args=" to append arguments (example: make php args='script.php') |
| 44 | + @$(PHP) ${args} |
| 45 | + |
| 46 | +## ✅ Code Quality |
| 47 | +hooks: ## Enable Git hooks |
| 48 | + git config --local core.hooksPath .hooks/ |
| 49 | + |
| 50 | +phpcs: ## Run PHP Code Sniffer |
| 51 | + @$(APP_CONTAINER) vendor/bin/phpcs |
| 52 | + |
| 53 | +phpcs-fix: ## Run PHP Code Sniffer (fix) |
| 54 | + @$(APP_CONTAINER) vendor/bin/phpcbf |
| 55 | + |
| 56 | +phpstan: ## Run PHPStan |
| 57 | + @$(APP_CONTAINER) vendor/bin/phpstan |
| 58 | + |
| 59 | +lint: phpcs phpstan ## Run PHP Code Sniffer and PHPStan |
| 60 | + |
| 61 | +test: ## Run all tests, pass the parameter "args=" to append arguments (example: make test args='--filter=file.php') |
| 62 | + @$(DOCKER_COMPOSE) exec app vendor/bin/phpunit --testdox ${args} |
| 63 | + |
| 64 | +test-cov: ## Run all tests and generate coverage report |
| 65 | + @$(DOCKER_COMPOSE) exec -e XDEBUG_MODE=coverage app vendor/bin/phpunit --testdox --coverage-clover coverage/clover/clover.xml --coverage-html coverage/html --log-junit coverage/junit.xml |
| 66 | + |
| 67 | +cov: test-cov cov-report ## Generate and open test coverage report |
| 68 | + |
| 69 | +cov-report: ## Open test coverage report |
| 70 | + open coverage/html/index.html |
| 71 | + |
| 72 | +## 🧙 Composer |
| 73 | +composer: ## Run Composer, pass the parameter "c=" to run a given command (example: make composer c='req vendor/package') |
| 74 | + @$(COMPOSER) $(c) |
0 commit comments