Last active
May 10, 2017 08:59
-
-
Save sdbruder/21716d63ba5de9fdc85fddb6fd7c68d0 to your computer and use it in GitHub Desktop.
New Laravel Project from Scratch to working fresh install
This file contains hidden or 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
#!/bin/bash | |
### | |
# | |
# newLaravelProject | |
# | |
# from an idea to a working freshly installed laravel in 26 seconds using | |
# composer create-project with prestissimo. | |
# | |
# Sergio Bruder <[email protected]> | |
# | |
### | |
### | |
# | |
# Assumptions: | |
# | |
# - your homestead environment will be callable as ssh homestead in your host; | |
# - homestead points to your VM in your host and to 127.0.0.1 inside the VM; | |
# - ~/src/$repo, http://$repo.app, DB $repo, all will be named accordingly; | |
# - your homestead is in 192.168.10.10. if not, please change it below; | |
# - you have /vagrant/scripts/serve-laravel.sh in working conditions; | |
# - your vagrant user in homestead has a working .my.cnf configured; | |
# - all your projects will reside on ~/src/$project on your home; | |
# - add #LARAVEL_LIST_START somewhere in your /etc/hosts file; | |
# | |
### | |
repo=$1 | |
# change /etc/hosts | |
sudo sed -i 'bak' '/#LARAVEL_LIST_START/a\ | |
192.168.10.10 '"$repo"'.app | |
' /etc/hosts | |
# setup nginx | |
ssh homestead "sudo bash /vagrant/scripts/serve-laravel.sh $repo.app /home/vagrant/src/$repo/public " | |
ssh homestead "sudo service nginx restart" | |
# create database | |
ssh homestead 'echo "create database '"$repo"';" | mysql' | |
# composer install the laravel project | |
cd ~/src | |
composer create-project --prefer-dist laravel/laravel $repo | |
# change .env to point to mysql in homestead | |
cd ~/src/$repo | |
sed -i 'bak' "s/DB_HOST=.*/DB_HOST=homestead/g" .env | |
sed -i 'bak' "s/DB_DATABASE=.*/DB_DATABASE=$repo/g" .env | |
# initial migrations | |
php artisan migrate | |
# initial commit | |
cd ~/src/$repo | |
git init . | |
git add -A . | |
git commit -m 'initial commit' | |
# open url in the browser | |
open "http://$repo.app" | |
echo "$repo project started, happy Laraveling." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment