Skip to content

Instantly share code, notes, and snippets.

@inhere
Last active July 6, 2019 03:11
Show Gist options
  • Save inhere/c98df2b096ee3ccc3d36ec61923c9fc9 to your computer and use it in GitHub Desktop.
Save inhere/c98df2b096ee3ccc3d36ec61923c9fc9 to your computer and use it in GitHub Desktop.
Makefile ref for php project
# link https://github.com/humbug/box/blob/master/Makefile
#SHELL = /bin/sh
.DEFAULT_GOAL := help
# 每行命令之前必须有一个tab键。如果想用其他键,可以用内置变量.RECIPEPREFIX 声明
# mac 下这条声明 没起作用 !!
.RECIPEPREFIX = >
.PHONY: all usage help clean
# 需要注意的是,每行命令在一个单独的shell中执行。这些Shell之间没有继承关系。
# - 解决办法是将两行命令写在一行,中间用分号分隔。
# - 或者在换行符前加反斜杠转义 \
# 接收命令行传入参数 make COMMAND tag=v2.0.4
TAG=$(tag)
##there some make command for the project
##
help:
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//' | sed -e 's/: / /'
##Available Commands:
clean: ## Clean all created artifacts
clean:
git clean --exclude=.idea/ -fdx
cs: ## Fix CS
cs: vendor-bin/php-cs-fixer/vendor/bin/php-cs-fixer
php -d zend.enable_gc=0 vendor-bin/php-cs-fixer/vendor/bin/php-cs-fixer fix
apidoc: ## Generate swagger UI document json
apidoc:
php bin/cli doc:gen --env-name dev --force
php bin/cli doc:gen --env-name test --force
php bin/cli doc:gen --env-name audit --force
php bin/cli doc:gen --env-name prod --force
route: ## Collection and generate routes file
route:
php bin/cli route:build -y
phar: ## Build the project PHAR
phar:
# Cleanup existing artefacts
#rm -f bin/box.phar
# Remove unnecessary packages
#composer install --no-dev --prefer-dist
# Re-dump the loader to account for the prefixing
# and optimize the loader
#composer dump-autoload --classmap-authoritative --no-dev
# Build the PHAR
php -d zend.enable_gc=0 -d phar.readonly=0 bin/cli app:pack
# Install back all the dependencies, revert
#composer install
sami: ## Gen classes docs
sami:
# rm -rf docs/classes-docs
rm -rf docs/classes-docs
# gen docs
php sami.phar update sami.doc.inc
pbimg: ## Build publish docker image and push to hub.youquoquan
pbimg: uem.phar
# build publish docker image
docker build -f docker/uem-publish.Dockerfile -t hub.youguoquan.com/u-social-apps/uem .
# Push to the hub.youguoquan
docker push hub.youguoquan.com/u-social-apps/uem
##
##Tests Commands:
test: ## Run all the tests
test: tu e2e
echo: ## echo test
echo:
echo hello
tu: ## Run the unit tests
tu: vendor/bin/phpunit
php -d phar.readonly=0 -d zend.enable_gc=0 bin/phpunit
tc: ## Run the unit tests with code coverage
tc: vendor/bin/phpunit
phpdbg -qrr -d phar.readonly=0 -d zend.enable_gc=0 phpunit --coverage-html=dist/coverage --coverage-text
#
# Rules from files
#---------------------------------------------------------------------------
composer.lock:
composer update
vendor: composer.lock
composer install
vendor/bamarni: composer.lock
composer install
vendor/bin/phpunit: composer.lock
composer install
vendor-bin/php-cs-fixer/vendor/bin/php-cs-fixer: vendor/bamarni
composer bin php-cs-fixer install
bin/box.phar: bin/box src vendor
$(MAKE) build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment