Skip to content

Instantly share code, notes, and snippets.

@roni-estein
Last active November 21, 2021 21:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save roni-estein/2351dfae05e062841335f0169f5a3651 to your computer and use it in GitHub Desktop.
Save roni-estein/2351dfae05e062841335f0169f5a3651 to your computer and use it in GitHub Desktop.
Shortcuts for Laravel & PHP Storm
export PATH="~/.composer/vendor/bin:$PATH"
export EDITOR='subl -w'
# export CLICOLOR=1
# export LSCOLORS=ExFxCxDxBxegedabagacad
#ALIASES
#COMMANDS
alias ..="cd .."
alias ...="cd ../.."
alias md='mkdir -pv'
alias h='cd ~'
alias c='clear'
alias l='ls -laF'
alias flush-cache='sudo killall -HUP mDNSResponder;say DNS cache has been flushed'
#PROMPT
#export PS1="\[$(tput bold)\]\[$(tput setaf 2)\]\W \[$(tput setaf 153)\]‣ \[$(tput sgr0)\]\[$(tput sgr0)\]"
#UTILITY
alias copy-key='pbcopy < ~/.ssh/id_rsa.pub'
alias edit-commands='subl ~/.settings/.bash_aliases;'
alias reload-commands='c; source ~/.settings/.bash_aliases; echo "Done."'
#ARTISAN COMMANDS
alias laravel='~/.composer/vendor/bin/laravel'
alias art='php artisan'
alias tinker='art tinker'
alias watch='c;yarn run watch'
alias dev='c;yarn run development'
alias prod='c;yarn run production'
alias last_file='lastFileFunction(){
dirname=$(ls -dt * | head -1)
echo $dirname
unset -f lastFileFunction
};lastFileFunction'
#GIT
alias gts='git status'
alias gtk='git checkout'
alias gtm='git checkout master'
alias gtc='git commit -a'
alias gtp='git push origin'
alias gta='git add .'
alias gtl='git log --pretty=format:"%h : %an : %ar : %s"'
alias gtrevert='git add -A .;git stash;git stash drop stash@{0}'
alias nah="git reset --hard && git clean -df"
alias wip="git add . && git commit -m 'WIP'"
alias gtep='function __complete_episode(){
echo processing $(($*))
git add .
git commit -m "completed episode $*"
git push origin master
c
echo "start working on episode $(($*+1))"
unset -f __complete_episode
}; __complete_episode'
#NPM
alias update-npm='c; echo "Updating NPM ..."; npm install npm@latest -g;c;echo "New NPM Version:"; npm -v'
#HELP
alias list='listFunction(){
c
echo "Laravel Helpers List"
echo "--------------------"
echo "NOTE: use directory/class for namespaced files"
echo ""
echo ""
echo "ft => Feature Test"
echo "ut => Unit Test"
echo "ts => Test Seeder (not the same as a regular db seeder)"
echo ""
echo "pc => Plain Controller"
echo "rc => Resourcefull Controller"
echo ""
echo "pm => Plain Model (Model with migration comming for now mn)"
echo ""
echo "fmm => Make a (namespaced: optional) Model with a migration and a factory"
echo ""
echo "nc => New Console Command"
echo "pe => Event"
echo "pl => Listener"
echo ""
echo "px => Exception"
echo "fr => Form Request"
echo "mw => Middleware"
echo "sp => Service Provider"
echo "mf => Model Factory"
echo "pr => Rule"
echo ""
echo "nv => New View File {path/to/name or path.name or name.blade.php}"
echo ""
echo "mn => New Migration, jsut the name of the table create_<posts>_table"
echo "mp => Plain Migration, mp add_something_to_posts posts"
echo ""
echo "VUE"
echo "--------------------"
echo "vc => Vue Component In components Directory (make into proper stub later)"
echo ""
unset -f listFunction
}; listFunction'
#VUE
#LARAVEL-VUE
alias vc='{ f=$(cat -); touch resources/assets/js/components/${f}.vue; pstorm resources/assets/js/components/${f}.vue;}<<<'
#LARAVEL
alias ft='{ f=$(cat -); php artisan make:test ${f}Test; pstorm tests/Feature/${f}Test.php;}<<<'
alias ut='{ f=$(cat -); php artisan make:test ${f}Test --unit; pstorm tests/Unit/${f}Test.php;}<<<'
alias pc='{ f=$(cat -); php artisan make:controller ${f}Controller; pstorm app/Http/Controllers/${f}Controller.php;}<<<'
alias rc='{ f=$(cat -); php artisan make:controller ${f}Controller -r; app/Http/Controllers/${f}Controller.php;}<<<'
alias pm='{ f=$(cat -); php artisan make:model ${f}; pstorm app/${f}.php;}<<<'
alias pe='{ f=$(cat -); php artisan make:event ${f}; pstorm app/Events/${f}.php;}<<<'
alias pl='{ f=$(cat -); php artisan make:listener ${f}; pstorm app/Listeners/${f}.php;}<<<'
alias nc='{ f=$(cat -); php artisan make:command ${f}; pstorm app/Console/Commands/${f}.php;}<<<'
alias px='{ f=$(cat -); php artisan make:exception ${f}; pstorm app/Exceptions/${f}.php;}<<<'
alias pr='{ f=$(cat -); php artisan make:request ${f}Request; pstorm app/Http/Requests/${f}Request.php;}<<<'
alias fr='{ f=$(cat -); php artisan make:request Forms/${f}Form; pstorm app/Http/Requests/Forms/${f}Form.php;}<<<'
alias mw='{ f=$(cat -); php artisan make:middleware ${f}; pstorm app/Http/Middleware/${f}.php;}<<<'
alias sp='{ f=$(cat -); php artisan make:provider ${f}Provider; pstorm app/Providers/${f}Provider.php;}<<<'
alias mf='{ f=$(cat -); php artisan make:factory ${f}Factory; pstorm database/factories/${f}Factory.php;}<<<'
alias pr='{ f=$(cat -); php artisan make:rule ${f}; pstorm app/Rules/${f}.php;}<<<'
alias nv='{ f=$(cat -); php artisan make:view ${f};}<<<'
alias ts='{ f=$(cat -); php artisan make:test-seeder ${f};}<<<'
alias fmm='{ f=$(cat -); php artisan test-resource:make ${f};}<<<'
alias mn='function __migrate-new-make(){
tab=$(php artisan make:migration create_$*_table --create=$* --table=$*);
pstorm database/migrations/${tab:19}.php;
unset -f __migrate-new-make;
}; __migrate-new-make'
alias mp='function __migrate-make(){
tab=$(php artisan make:migration $1 --table=$2);
pstorm database/migrations/${tab:19}.php;
unset -f __migrate-make;
}; __migrate-make'
alias tailwind='c;./node_modules/.bin/tailwind'
alias migrate='php artisan migrate'
alias fresh='redis-cli flushall; php artisan migrate:fresh'
alias rlist='php artisan route:list'
alias cda='composer dump-autoload -o'
#HELP
alias tests='listFunction(){
c
echo "Laravel Test List"
echo "--------------------"
echo "NOTE: use directory/class for namespaced files"
echo ""
echo ""
echo "phpspec => <current directory>/vendor/bin/phpspec"
echo "phpunit => <current directory>/vendor/bin/phpunit"
echo ""
echo "Unless you are testing a specific tet that runs external implementation"
echo "dont run the external group, adding f will will let you filter down to a specific"
echo "group or directory"
echo ""
echo "If you are testing a specific tet that runs external implementation"
echo "p => php -n vendor/bin/phpunit --exclude-group external"
echo "pf => php -n vendor/bin/phpunit --exclude-group external --filter"
echo ""
echo ""
echo "If you are testing a specific test that DOES run external implementations"
echo "use pext, to filter add the f as well pextf"
echo ""
echo "pext => php -n vendor/bin/phpunit --exclude-group external"
echo "pextf => php -n vendor/bin/phpunit --exclude-group external --filter"
unset -f listFunction
}; listFunction'
#TESTING PHPUNIT
alias phpspec='c;vendor/bin/phpspec'
alias phpunit='c;vendor/bin/phpunit'
alias p='c;php -n vendor/bin/phpunit --exclude-group external'
alias pf='c;php -n vendor/bin/phpunit --exclude-group external --filter '
alias pext='c;php -n vendor/bin/phpunit'
alias pextf='c;php -n vendor/bin/phpunit --filter '
#LOCATIONS
alias 57='cd ~/code/php/laravel/5.7'
alias 56='cd ~/code/php/laravel/5.6'
alias 55='cd ~/code/php/laravel/5.5'
alias 54='cd ~/code/php/laravel/5.4'
alias 53='cd ~/code/php/laravel/5.3'
alias idf='cd ~/code/php/laravel/5.6/idfashion'
alias munroe='cd ~/code/php/laravel/5.7/munroe'
alias pie='cd ~/code/php/laravel/5.7/pie'
alias dna='cd ~/code/php/laravel/5.6/bookkeepingdna'
alias petra='cd ~/code/php/laravel/5.6/petra'
alias forum='cd ~/code/php/laravel/5.5/forum'
alias library='cd /Volumes/nas1/library/'
#LOCAL BACKUPS
#1. RESTORE
alias restore-local-db='backupDBFunction(){
c
thisdir=$(pwd)
projDir=${PWD##*/} # to assign to a variable
cd ..
versionDir=${PWD##*/}
cd $thisdir
dbname=${projDir}_${versionDir}
dbname=${dbname//./_}
echo "restoring local-backup to $dbname"
cd database/backups/last
lastbackup=$(ls -dt * | head -1)
mysql -u root -e "DROP DATABASE IF EXISTS $dbname";
mysql -u root -e "create database $dbname";
mysql -u root $dbname < $lastbackup
cd $thisdir
echo "Restored: $lastbackup"
unset -f backupDBFunction
};backupDBFunction'
#2. BACKUP
alias backup-local-db='backupDBFunction(){
c
projDir=${PWD##*/} # to assign to a variable
thisdir=$(pwd)
cd ..
versionDir=${PWD##*/}
cd $thisdir
dbname=${projDir}_${versionDir}
dbname=${dbname//./_}
echo "Backing up: $dbname"
cd database/backups/last
mv *.sql ../
mysqldump -u root $dbname > $projDir-backup-$(date +"%Y%m%d_%H%M%S").sql
lastbackup=$(ls -dt * | head -1)
cd $thisdir
echo Backed Up: $lastbackup
unset -f backupDBFunction
};backupDBFunction'
#SERVER BACKUPS
alias restore-dev-db='backupDBFunction(){
c
mysql -u root munroe < munroepharmacy.com/database/backups/munroe-last.sql
unset -f backupDBFunction
};backupDBFunction'
alias restore-server-db='backupDBFunction(){
c
mysql -u root munroe < munroepharmacy.com/database/backups/munroe-server-last.sql
unset -f backupDBFunction
};backupDBFunction'
alias restore-backup-db='backupDBFunction(){
c
thisdir=$(pwd)
cd ~/munroepharmacy.com/database/backups/
lastbackup=$(ls -dt * | head -1)
mysql -u root munroe < $lastbackup
cd $thisdir
echo "Restored: $lastbackup"
unset -f backupDBFunction
};backupDBFunction'
# BACKUPS
alias backup-db='backupDBFunction(){
c
thisdir=$(pwd)
cd ~/munroepharmacy.com/database/backups/last
mv *.sql ../
mysqldump -u root munroe > munroe-backup-$(date +"%Y%m%d_%H%M%S").sql
cd $thisdir
unset -f backupDBFunction
};backupDBFunction'
# OSX
# ITUNES SYNC WITHOUT BACKUP
alias sync-no-backup='defaults write com.apple.iTunes DeviceBackupsDisabled -bool true';
alias sync-w-backup='defaults write com.apple.iTunes DeviceBackupsDisabled -bool false';
recursiveDelete() {
echo "DELETING: ${1}"
find . -name ${1} -delete
}
alias rr='recursiveDelete'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment