Skip to content

Instantly share code, notes, and snippets.

@stecman
Last active August 30, 2015 11:28
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 stecman/dace655824a4515070ed to your computer and use it in GitHub Desktop.
Save stecman/dace655824a4515070ed to your computer and use it in GitHub Desktop.
Shell helper function for starting PHP dev servers
# Run a PHP dev server on the first available port starting at 8000
function serve()
{
local port=8000
# Try ports until an unused one is found
while nc -z localhost $port > /dev/null; do ((port++)); done;
echo -e "\033[44m>> Listening on port $port <<\033[0m"
php -S "0.0.0.0:$port" "$@";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment