Last active
August 29, 2015 14:05
-
-
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
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
# !/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