Skip to content

Instantly share code, notes, and snippets.

@Sherlockboy
Created November 22, 2023 10:08
Show Gist options
  • Save Sherlockboy/3d327c94732856fed51799beff16d4d9 to your computer and use it in GitHub Desktop.
Save Sherlockboy/3d327c94732856fed51799beff16d4d9 to your computer and use it in GitHub Desktop.
Makefile template for Laravel and Sail
.PHONY: help
SAIL := ./vendor/bin/sail
help: ## Display all available commands.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-10s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
install: ## Setup project and install dependencies.
@cp .env.example .env
@cp .env.example .env.testing
@sed -i~ 's/DB_DATABASE=.*/DB_DATABASE=testing/g' .env.testing
@composer install
@npm install
@npm run dev
@php artisan key:generate
start: ## Start containers.
$(SAIL) up -d
stop: ## Stop containers.
$(SAIL) stop
migrate: ## Migrate database migrations.
$(SAIL) artisan migrate
migrate-seed: ## Migrate database migrations and seed dummy data.
$(SAIL) artisan migrate --seed
migrate-fresh-seed: ## Refresh database, migrate database migrations and seed dummy data.
$(SAIL) artisan migrate:fresh --seed
test-db: ## Setup testing database.
$(SAIL) artisan migrate:fresh --seed --env=testing
clear: ## Clear application and configuration cache.
$(SAIL) artisan optimize:clear
optimize: ## Cache config and routes.
$(SAIL) artisan optimize && $(SAIL) artisan route:trans:cache
deploy: ## Deploy app inside hosting
sh deploy.sh
deploy-remote: ## Deploy app to hosting remotely
sh deploy-remote.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment