Last active
December 22, 2020 12:19
-
-
Save tabacitu/bc615e061697e22bf9d88c12087cf5e0 to your computer and use it in GitHub Desktop.
Quickly create a Backpack Demo, serve it with Laravel Valet, open it with Sublime Text and Brave Browser on Mac OS X
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
# alias to the subl command | |
# for it to work, you need to create a symlink to the subl command somewhere in the PATH | |
# ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl | |
alias sublime='subl' | |
# function to open the current directory in the browser, served by Laravel Valet | |
safari() { | |
open 'http://'$(basename $(pwd))'.test/'; | |
} | |
# function to open the current directory in the Brave Browser, served by Laravel Valet | |
brave() { | |
open -a /Applications/Brave\ Browser.app 'http://'$(basename $(pwd))'.test/'; | |
} | |
# function to start working on a Laravel Valet project; opens it in Brave, in Sublime and runs a git status | |
work() { | |
brave | |
subl . | |
git status | |
} | |
# function to install a new backpack demo, with a give name | |
newdemo() { | |
mysql -u root -e "CREATE DATABASE IF NOT EXISTS \`$*\` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;" | |
git clone https://github.com/Laravel-Backpack/demo.git ~/Sites/$* | |
cd ~/Sites/$* | |
composer install | |
cp ~/backpack-demo.example.env ~/Sites/$* #copy .env example file to current directory | |
mv ~/Sites/$*/backpack-demo.example.env ~/Sites/$*/.env #correct name for .env file | |
sed -i '' 's/backpack-demo/'$*'/g' ~/Sites/$*/.env #change DB_DATABASE and APP_URL in .env file | |
php artisan key:generate | |
php artisan migrate | |
php artisan db:seed --class="Backpack\Settings\database\seeds\SettingsTableSeeder" | |
php artisan db:seed | |
php artisan backpack:base:user --name='Cristian Tabacitu' --email="[email protected]" --password="mydefaultpassword" | |
#get all backpack packages again, with version control | |
rm -rf vendor/backpack | |
composer install --prefer-source | |
#open text editor and see status | |
work | |
} | |
# undo the changes in a repo to the last git commit | |
# (deletes new files, reverts changes to files) | |
nah() { | |
git clean -f -d | |
git reset --hard HEAD | |
} | |
# function to delete a laravel project, with a given folder name | |
# assumes folder name and database name are the same | |
dump() { | |
if [ $# -eq 0 ]; then | |
echo 'Please specify the name of the project you want to dump.' | |
else | |
echo 'Dumping folder Sites/'$* | |
rm -rf ~/Sites/$* | |
echo 'Dumping MySQL database '$* | |
mysql -u root -e "DROP DATABASE \`$*\`;" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment