Last active
December 29, 2015 07:59
-
-
Save ahmadshah/7639827 to your computer and use it in GitHub Desktop.
Laravel builder bash script
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
#!/bin/bash | |
echo "Laravel 4 Project Builder" | |
echo -n "What is the project name? " | |
read -e PROJECT | |
echo -n "Which folder will I be working on? [eg: /Users/foo/bar] " | |
read -e DIR | |
if [ ! -d $DIR ] | |
then | |
echo -n "Should I create the directory for you? [yes|no] " | |
read -e CREATEDIR | |
if [ $CREATEDIR = 'yes' ] | |
then | |
echo "Creating directory..." | |
mkdir $DIR | |
else | |
echo "Please create the directory manually and rerun the script" | |
exit 1 | |
fi | |
fi | |
cd $DIR | |
echo -n "Do you want to create a new database or use existing database? [new|existing] " | |
read -e DATASOURCE | |
echo -n "What is the name of the database? " | |
read -e DATABASE | |
echo -n "Do you want to add prefix to the tables? [ENTER for blank] " | |
read -e PREFIX | |
echo -n "MySQL username: " | |
read -e MYSQLUSERNAME | |
echo -n "MySQL password: [ENTER for blank] " | |
read -e MYSQLPASSWORD | |
if [ $DATASOURCE = 'new' ] | |
then | |
echo "Creating new MySQL database..." | |
if [ -z $MYSQLPASSWORD ] | |
then | |
mysql -u$MYSQLUSERNAME -e "CREATE DATABASE $DATABASE" | |
else | |
mysql -u$MYSQLUSERNAME -p$MYSQLPASSWORD -e "CREATE DATABASE $DATABASE" | |
fi | |
fi | |
echo "Installing Laravel Framework..." | |
composer create-project laravel/laravel | |
mv laravel $PROJECT | |
cd $PROJECT | |
chmod -R 777 app/storage | |
gsed -i "0,/'database' => 'database'/s//'database' => '$DATABASE'/" app/config/database.php | |
gsed -i "0,/'username' => 'root'/s//'username' => '$MYSQLUSERNAME'/" app/config/database.php | |
gsed -i "0,/'password' => ''/s//'password' => '$MYSQLPASSWORD'/" app/config/database.php | |
gsed -i "0,/'prefix' => ''/s//'prefix' => '$PREFIX'/" app/config/database.php | |
php artisan --version |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This one is for OSX and it is using gnu-sed
brew install gnu-sed