wyrihaximus/makefiles
Reusable Makefile building blocks for PHP projects. Install via Composer and compose consistent, CI-friendly targets across repositories without rewriting common rules. Minimal package focused on sharing standardized Makefile snippets and workflows.
Installation:
composer require wyrihaximus/makefiles
This package generates a Makefile in your project root, providing standardized build blocks for common Laravel development tasks.
First Use Case:
Run make in your terminal to see available commands. Key starter commands include:
make all # Run all QA checks (static analysis, tests, code style)
make test # Run unit tests
make cs # Run code style checks (PHP-CS-Fixer)
make cs-fix # Auto-fix code style issues
Where to Look First:
Makefile: Auto-generated in your project root. Customize by overriding variables or adding new rules.composer.json: Configure supported features (e.g., disable code-style or unit-tests) under "extra.wyrihaximus.supported-features".etc/ directory: Contains config files for tools like PHPStan, PHP-CS-Fixer, and InfectionPHP (auto-generated or manually editable).# Auto-generated Docker rule (override in your Makefile)
DOCKER_RUN ?= docker run --rm -v $(PWD):/app -w /app $(DOCKER_OPTS)
DOCKER_OPTS to pass Laravel-specific flags (e.g., --network=host for database access):
DOCKER_OPTS += --network=host
composer.json:
{
"extra": {
"wyrihaximus": {
"supported-features": {
"static-analysis": false, // Disable PHPStan
"unit-tests": true,
"code-style": true
}
}
}
}
static-analysis for legacy projects or enable windows support if using WSL.test-with-mutations:
$(MAKE) test
$(MAKE) infection
migrate:
$(DOCKER_RUN) php artisan migrate --env=testing
etc/. Example: Customize PHPStan (etc/phpstan.neon):
includes:
- vendor/laravel/framework/src/Rules
excludeFiles:
- vendor/laravel/**
- storage/**
make shell for an interactive Docker shell with all dependencies pre-installed:
make shell
shell:
$(DOCKER_RUN) bash -c "source .env && bash"
artisan:
$(DOCKER_RUN) php artisan $@
db-seed:
$(DOCKER_RUN) php artisan db:seed --class=UserTableSeeder
make all in GitHub Actions or GitLab CI for standardized QA:
# .github/workflows/ci.yml
jobs:
test:
runs-on: ubuntu-latest
steps:
- run: make all
Docker Socket Overhead:
--privileged) can slow down builds.DOCKER_OPTS ?= $(if $(filter test-container%,$(MAKECMDGOALS)),--privileged,)
Config File Conflicts:
etc/phpstan.neon) may conflict with manual edits.make cs-fix-debug to inspect conflicts before applying fixes.ZTS (Zend Thread Safety) Quirks:
composer.json:
"extra": {
"wyrihaximus": {
"supported-features": {
"zts": false
}
}
}
Windows Support:
C:\) break Makefile rules."supported-features": {
"windows": false
}
Dependency Bloat:
make all installs all dev dependencies, even if unused.composer require --dev selectively or override the on-install-or-update rule.VERBOSE=1 to see raw commands:
VERBOSE=1 make test
make test DOCKER_OPTS="--entrypoint=sh -c 'echo $$(which php)'"
etc/qa/ logs for tool-specific errors (e.g., phpstan.log).Custom Rules:
Makefile:
deploy:
$(DOCKER_RUN) php artisan deploy
on-install-or-update for dependency setup:
deploy: on-install-or-update
Tool Overrides:
PHPSTAN_BIN ?= ./vendor/bin/custom-phpstan
Environment Variables:
DOCKER_ENV += APP_ENV=testing DB_CONNECTION=sqlite_test
Git Hooks:
pre-commit:
$(MAKE) cs-fix
$(MAKE) test-unit
"supported-features": {
"code-style": { "exclude": ["resources/js"] }
}
test:
$(DOCKER_RUN) ./vendor/bin/pest
sail-up:
docker-compose -f docker-compose.yml up -d
sail-test:
$(MAKE) test DOCKER_OPTS="--network=laravel"
How can I help you explore Laravel packages today?