Created
August 29, 2017 09:25
-
-
Save allebb/303459a2d895274a7c1b4785074a3ed0 to your computer and use it in GitHub Desktop.
Laravel makefile for projects with Git and MySQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# == Git repo == | |
repo=my_awesome_repo | |
# === Artisan ==== | |
p=8000 | |
# ===== DB ======= | |
db_username=user | |
db_password=password | |
db_name=laravel | |
db_file=my_db.sql | |
# === Server connection ===== | |
port=8080 | |
url=ssh@myip | |
# = Requirements = | |
file="requirements.txt" | |
# ================ | |
help: ##Shows help | |
@cat makefile | grep "##." | sed '2d;s/##//;s/://' | |
serve: ##Serves the environment into given port (8000 by default) | |
@php artisan serve --port $(p) | |
load: ##Dumps the autoloader | |
@composer dumpautoload | |
migrate: ##Runs migrations | |
@php artisan migrate | |
rollback: ##Does a rollback | |
@php artisan migrate:rollback | |
connect: ##Connects to server | |
@ssh $(url) -p$(port) | |
db-sync: ##Gets database from server and syncs it with local. Requires db_username, db_password, db_name | |
@echo "Downloading development DB, trying to connect to server" | |
@scp -P $(port) $(url):$(db_file) . | |
@echo "Populating local DB, this may take a while" | |
@mysql -u $(db_username) --password=$(db_password) $(db_name) < $(db_file) | |
db-connect: ##Connects to local database | |
@mysql -u $(db_username) -p$(db_password) $(db_name) | |
install: ##Installs dependencies from a given path (requirements.txt by default) | |
@sudo apt-get install $(<$(file)) | |
up: install db-sync ##then installs composer, clones the repo and enables mcrypt | |
@echo "Setting composer" | |
@curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer | |
@echo "Cloning repo" | |
@git clone $(repo) | |
@echo "Enabling mcrypt" | |
@sudo php5enmod mcrypt | |
.PHONY: help |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git | |
curl | |
php5-cli | |
php5-mcrypt | |
php5-json | |
php5-gd | |
mysql-server | |
mysql-client | |
php5-mysql | |
php5-curl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment