Last active
August 30, 2015 11:28
-
-
Save stecman/dace655824a4515070ed to your computer and use it in GitHub Desktop.
Shell helper function for starting PHP dev servers
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
# 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