With this bash script you can automate the creation of laravel projects; Use this script to auto create a laravel script using the laravel command.

Requirements:

  1. Linux Ubuntu 20 TLS
  2. PHP 7
    - PHP 7.4.3 (cli) (built: Oct  6 2020 15:47:56) ( NTS )
  3. Apache2
    - Server version: Apache/2.4.41 (Ubuntu)
    -  Server built:   2020-08-12T19:46:17
  4. Composer
    - version 2.0.9 2021-01-27 16:09:27
  5. Laravel 8
    - Laravel Installer 4.1.1

laravel_new.sh

#!/bin/bash
# this is a goog step by step tutorial on how to run laravel command in ubuntu:
# https://www.technhit.in/setup-laravel-on-ubuntu-with-apache/
# Script Created by https://www.webune.com
clear
APPNAME_DEFAULT="api"
read -p "Enter The App you want to Create: [$APPNAME_DEFAULT] " APPNAME
if [[ $APPNAME == "" ]]
then
    APPNAME=$APPNAME_DEFAULT
    set -e
fi
#https://stackoverflow.com/questions/59838/how-can-i-check-if-a-directory-exists-in-a-bash-shell-script
# check if directory exists
if [ -d "$APPNAME" ]; then
  ORVERIDE_DEFAULT="no"
  read -p "This app already exists, do you want to overide it? yes/no [$ORVERIDE_DEFAULT] " ORVERIDE
  if [[ $ORVERIDE == "yes" ]]; then
    rm -rf $APPNAME
    set -e
    echo "Rebuilding App $APPNAME"      
  else
        echo "$APPNAME was not removed."
        exit
        set -e
  fi
else
    echo "[OK] APP DOES NOT EXIST. WILL CREATE NOW."
fi
echo "Creating APP: $APPNAME"
laravel new $APPNAME
set -e
cd $APPNAME
set -e
git init
set -e
git add .
set -e
git commit -m "Auto Initial"
set -e
echo "GIT commit created"
code .
echo "Opening in Code and browser with localhost:8000"
xdg-open http://localhost:8000
set -e
# ALWAYS PUT THIS AT THE END OF THE SCRIPT
php artisan serve
set -e