Skip to content

Instantly share code, notes, and snippets.

@selimhex
Last active May 31, 2020 12:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save selimhex/974d7e07f8638eaf17378003efc0da0e to your computer and use it in GitHub Desktop.
Save selimhex/974d7e07f8638eaf17378003efc0da0e to your computer and use it in GitHub Desktop.
bash alias function to start a local php server anywhere
# 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