From 378fa5bec44d3b93b3b170e6f27f5e89c277e2e2 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Tue, 7 Aug 2012 11:13:45 +0200 Subject: .functions: Add `phpserver` Ref. #116. --- .functions | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.functions b/.functions index 71f95cc..f35f483 100644 --- a/.functions +++ b/.functions @@ -29,6 +29,15 @@ function server() { python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nSimpleHTTPServer.test();' "$port" } +# Start a PHP server from a directory, optionally specifying the port +# (Requires PHP 5.4.0+.) +function phpserver() { + local port="${1:-4000}" + local ip=$(ipconfig getifaddr en1) + sleep 1 && open "http://${ip}:${port}" & + php -S "${ip}:${port}" +} + # Get gzipped file size function gz() { echo "orig size (bytes): " -- cgit v1.2.3