Skip to content

Instantly share code, notes, and snippets.

@kennwhite
Last active August 29, 2015 14:05
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 kennwhite/11ba4cbb5848cbf9dc4c to your computer and use it in GitHub Desktop.
Save kennwhite/11ba4cbb5848cbf9dc4c to your computer and use it in GitHub Desktop.
Launch php page in Safari from localhost built-in server, in current directory
# !/bin/bash
# Requires OSX Mavericks for php 5.4+
#
# Instantiate stand-alone server, suppress all stdout logging from php & bash job messages
echo '<?php phpinfo();' > info.php && { php -S localhost:8000 >/dev/null 2>&1 & } 2>/dev/null
sleep 2
osascript \
-e 'tell application "Safari" to activate' \
-e "tell app \"Safari\" to open location \"http://localhost:8000/info.php?foo=bar\""
PHP_PROC=$!
# When needed
# kill -9 -$PHP_PROC ; wait $PHP_PROC 2>/dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment