Skip to content

Instantly share code, notes, and snippets.

@dimitriacosta
Last active August 1, 2021 19:20
Show Gist options
  • Save dimitriacosta/d8dd4d65ed49ba156e549dcf9458e031 to your computer and use it in GitHub Desktop.
Save dimitriacosta/d8dd4d65ed49ba156e549dcf9458e031 to your computer and use it in GitHub Desktop.
Creates a new laravel project, initializes a git repository, creates its database and open in browser and editor
function laramagic {
PROJECT=$1
echo "Creating a new Laravel project: $PROJECT..."
cd ~/code
composer create-project laravel/laravel $PROJECT
cd $PROJECT
git init
git add .
git commit -m "Install Laravel"
mysql -u root -e "CREATE DATABASE $PROJECT"
sed -i'.original' -e "s/DB_DATABASE=homestead/DB_DATABASE=$PROJECT/g" .env
sed -i'.original' -e "s/DB_USERNAME=homestead/DB_USERNAME=root/g" .env
sed -i'.original' -e "s/DB_PASSWORD=secret/DB_PASSWORD=/g" .env
php artisan migrate
open "http://$PROJECT.test"
code .
rm .env.original
echo "$PROJECT project created succesfully"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment