Skip to content

Instantly share code, notes, and snippets.

Last active November 10, 2023 20:10
Show Gist options
  • 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
##help: List available tasks on this project
@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
$(DOCKER_COMPOSE) build --no-cache
.PHONY: build
##start: Start containers and make sure they are ready
$(DOCKER_COMPOSE) up --pull --wait -d
.PHONY: start
##stop: Kill all containers
.PHONY: stop
##clean: Remove all containers with their volumes
$(DOCKER_COMPOSE) down -v --remove-orphans || true
.PHONY: clean
##logs: tail PHP container logs
.PHONY: logs
##bash: access the PHP container's bash
$(DOCKER_COMPOSE) exec php sh -l
.PHONY: bash
##composer: run composer commands [use `--` if multiple arguments]
$(DOCKER_COMPOSE) exec php composer $(filter-out $@,$(MAKECMDGOALS))
.PHONY: composer
##console: run symfony's console commands [use `--` if multiple arguments]
$(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]
$(DOCKER_COMPOSE) exec php vendor/bin/$(filter-out $@,$(MAKECMDGOALS))
.PHONY: vbin
Copy link

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


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