Last active
May 31, 2020 12:24
-
-
Save selimhex/974d7e07f8638eaf17378003efc0da0e to your computer and use it in GitHub Desktop.
bash alias function to start a local php server anywhere
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
# a primitive alias function to start a local php server | |
# add this function to ~/.bash_profile and restart terminal | |
# $ stphpserverhere or $ stp[tab] | |
# no arguments starts the server at the current directory (pwd) | |
# stphpserverhere 0 > starts the server at the default root | |
# stphpserverhere ~/Documents/anotherDir starts the server at anotherDir. | |
stphpserverhere() { | |
serverroot=$(pwd) | |
echo $serverroot | |
if [[ $1 == "0" ]] | |
then serverroot=~/Documents/WEB # your default root | |
elif [[ $1 != "" ]] | |
then serverroot=$1 | |
fi | |
echo $serverroot | |
php -S 0.0.0.0:80 -t "$serverroot" # http://localhost | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment