Skip to content

Instantly share code, notes, and snippets.

@dgoosens
Last active November 10, 2023 20:10
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dgoosens/a5866ba4ccc5098c4410fd638f6c1dae to your computer and use it in GitHub Desktop.
Save dgoosens/a5866ba4ccc5098c4410fd638f6c1dae to your computer and use it in GitHub Desktop.
FrankenPHP- APIPlatform Makefile
DOCKER_COMPOSE=docker compose
.DEFAULT_GOAL := help
##help: List available tasks on this project
help:
@echo ""
@echo "These are the available commands"
@echo ""
@grep -E '\#\#[a-zA-Z\.\-]+:.*$$' $(MAKEFILE_LIST) \
| tr -d '##' \
| awk 'BEGIN {FS = ": "}; {printf " \033[36m%-30s\033[0m %s\n", $$1, $$2}' \
##build: Build all docker images
build:
$(DOCKER_COMPOSE) build --no-cache
.PHONY: build
##start: Start containers and make sure they are ready
start:
$(DOCKER_COMPOSE) up --pull --wait -d
.PHONY: start
##stop: Kill all containers
stop:
$(DOCKER_COMPOSE) kill
.PHONY: stop
##clean: Remove all containers with their volumes
clean:
$(DOCKER_COMPOSE) down -v --remove-orphans || true
.PHONY: clean
##logs: tail PHP container logs
logs:
$(DOCKER_COMPOSE) logs -f
.PHONY: logs
##bash: access the PHP container's bash
bash:
$(DOCKER_COMPOSE) exec php sh -l
.PHONY: bash
##composer: run composer commands [use `--` if multiple arguments]
composer:
$(DOCKER_COMPOSE) exec php composer $(filter-out $@,$(MAKECMDGOALS))
.PHONY: composer
##console: run symfony's console commands [use `--` if multiple arguments]
console:
$(DOCKER_COMPOSE) exec php bin/console $(filter-out $@,$(MAKECMDGOALS))
.PHONY: console
##vbin: run any `bin` script, with arguments, located in your `vendor/bin` [use `--` after the binary]
vbin:
$(DOCKER_COMPOSE) exec php vendor/bin/$(filter-out $@,$(MAKECMDGOALS))
.PHONY: vbin
@dgoosens
Copy link
Author

dgoosens commented Oct 27, 2023

Very basic list of make commands that can be used within FrankenPHP/APIPlatform projects
Or any project based on Symfony running within a Docker container...

Run make help to get the list of commands

ksnip_20231103-100743

make console will list all the Symfony Console commands...
and you just need to append those commands

for instance

make console debug:route

make composer will do the same for composer
for instance

make composer -- req --dev phpunit

(do remember to add -- if there is more than one argument for both the make console and make composer commands

UPDATE 2023-11-03

added the vbin command
this allows to run any script located in the vendor/bin directory

# example
make vbin schema 
make vbin simple-phpunit

# if you need to pass arguments to the script, use `--`
make vbin schema -- -h

comes in handy to run things like phpunit or phpstan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment