Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
run local php server and open browser
# local PHP Server
server() {
url="localhost:${2:-8000}"
if [ -z "$1" ]; then
php -S $url & # run server in background
else
php -S $url -t $1 &
fi
sleep 0.3s # wait for server to start
open http://$url # open browser
fg # back to server process
}
# Usage:
# server {directory} {port}
#
# default directory is the current one
# default port is 8000
# PHP’s built-in server is avaible since version 5.4 (pre-installed on Mavericks)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.