In your ~/yourloginname/Sites directory, place the following code in a index.php file there.

BEWARE: this code is only intended to be functional, not pretty ... you've been warned :)

Functionally, it provides a vertical set of ugly green navigation buttons that take you to each different site (in a sub-folder) that you might be working with on your localhost

<!DOCTYPE html> 
<html>
	<head>
		<style type="text/css">
			/*reset stuff*/
			html, body, div, span, object, iframe,
			h1, h2, h3, h4, h5, h6, p, blockquote, pre,
			abbr, address, cite, code,
			del, dfn, em, img, ins, kbd, q, samp,
			small, strong, sub, sup, var,
			b, i,
			dl, dt, dd, ol, ul, li,
			fieldset, form, label, legend,
			table, caption, tbody, tfoot, thead, tr, th, td,
			article, aside, canvas, details, figcaption, figure, 
			footer, header, hgroup, menu, nav, section, summary,
			time, mark, audio, video {
			    margin:0;
			    padding:0;
			    border:0;
			    outline:0;
			    font-size:100%;
			    vertical-align:baseline;
			    background:transparent;
			}

			body {
			    line-height:1;
				padding: 10px;
			}
		
			/*navigation stuff*/
			
			ul.nav { 
				margin: 0; 
				padding: 0; 
				list-style-type: none;
				width: 15em;
				background-color: #88D400;
			}

			ul.nav a {
				display: block;
				color: #2B3F00;
				text-decoration: none;

				border-top:    1px solid #E4FFD3; 
				border-right:  1px solid #486B02; 
				border-bottom: 1px solid #486B02; 
				border-left:   1px solid #E4FFD3; 

				background: url(./arrow.gif) no-repeat 5% 50%; 
				padding: 0.3em 1.5em;
			}

			ul.nav .last a {
				border-bottom: 0px;
			}

			ul.nav a:hover, ul.nav a:focus, ul.nav .selected a {
				color:#e4ffd3;
				background-color: #6da203;
			}

			.phpinfo {
				font-family: monospace;
				color: #44b;
			}
		
		</style>
	</head>
	<body>
		<h1>Jay iMac</h1>
		<p>http://localhost/~jaypersonius/Sites/</p>
		<br />
		<div class="phpinfo">
			<?php echo "HTTP_HOST       = " . $_SERVER["HTTP_HOST"] ?><br />
			<?php echo "DOCUMENT_ROOT   = " . $_SERVER["DOCUMENT_ROOT"] ?><br />
			<?php echo "SCRIPT_FILENAME = " . $_SERVER["SCRIPT_FILENAME"] ?><br />
		</div>
		<br />
		<ul class="nav">
		<?php 
			$dir = '.'; 
			$filelist = scandir($dir) or die ("Not a directory");
			foreach ($filelist as $file) {
				if ($file != '.' && $file != '..') {
					if (!is_file("$dir/$file")) {
						// echo "$file is a directory" . "<br />";
						echo "<li>";
						echo "<a href=\"$file\">$file</a>";
						echo "</li>";
					}
				}
			}
		?>
		</ul>
		<br />
		<div id="phpinfo"><?php echo phpinfo(); ?></div>
	</body>
</html>

Make sure Apache on OSX is pointing to your own ~/yourloginname/Sites directory first (see my article Enabling Apache web server on Mountain Lion (OSX 10.8)). If you wish to have your server point somewhere else on your hard drive, then change the 1st line of this article to match your desired folder path

 

Background:

IPA is an international phonetic character set (with some extra markings) that help singers sing in any language by just learning how each phoneme is to be pronounced (easier said than done). Currently many who want to write out or print out a song's words in IPA, either have to do it by hand, or make use of the very unproductive, finger twisting, immensely inefficient "Symbols" option in tools like MSWord.
There's a better way - install a keyboard layout on your Mac and install a reputable version of the IPA font. If that is what you want to do, then read on!

Note:Windows and Linux is also supported by following various links within these instructions

For Mac OSX users

(tested on 10.6 Snow Leopard)

There are 3 simple things that need to be done to enable typing IPA directly into a text document (as opposed to the very cumbersome use of MSWord's Insert Symbol hassle).

1) Install a keyboard layout file and re-login

  • Retrieve the IPA keyboard layout
    • To download the layout immediately right from this page
    • To navigate to the original web pages (in case you would like to find other alternatives and options along your way, or in case there might be a newer update)
      • Navigate in your browser to IPA Keyboard.
      • Scroll down to the subheading "Mac OS X Keyboards" (about 4 screen pages worth).
      • Continue down past the sub-subheading "IPA Unicode 5.1 Macintosh Keyboard v1.4".
      • Then down to the sub-sub-subheading "Download".
      • Click on the hotlink "Download "IPA-MACkbd.dmg"" under the entry for "IPA Unicode 5.1 Macintosh Keyboard v1.4" which downloads your downloads folder.
  • Install the IPA keyboard layout
    • Depending on your personal settings, the downloaded .dmg file might auto-launch. If not, then double-click it (from within your downloads folder) and it will open a custom finder installer window.
    • In this window, there will be two files: 1) a .pdf file to let you know what keys to press etc., and 2) a keyboard layout file you need to install. Save a copy of the .pdf file elsewhere on your hard drive for later use (drag it somewhere) because its presently only located within your .dmg file.
    • Open a 2nd finder window and navigate to the location YourHardDriveName - Library - Keyboard Layouts.
    • Drag a copy of the file called "IPA Unicode 5.1(v1.4) MAC.keylayout" to this Keyboard Layouts folder.
    • Installing the layout in this folder will allow anyone who logs into your computer to use the layout (provided they also follow other pertinent installation instructions for their login).
    • Dismount the disk image by clicking the eject icon next to the "Keyboard" entry under DEVICES in a finder window.
  • Log out and back in again
  • Notes − README (to save you from wasting time)
    • You won't see anything different yet until you complete step 2.
    • Read the file you dragged off for later use called "IPA Unicode 5.1 (v1.4) MAC Keyboard.pdf" − which explains how to use the keyboard layout successfully. Without using the "deadkey" sequence, your IPA keyboard will likely work like any other English (USA) keyboard and allows you to type normally in most cases without changing back and forth between keyboard layouts when you need to type normally.
    • Various fonts and tools on the www.sil.org site have licenses. Individual users are responsible for how they use such freely offered resources referenced in this article as terms may change or be updated from time to time.

2) Enable international keyboard capabilities

  • Enable the IPA keyboard layout
    • Open your System Preferences application (from your Dock, or from the Apple menu in the top left of your screen)
    • Select the icon in the top row called "Language & Text" (Note: As of this posting, the included instructions in the "IPA Unicode 5.1 (v1.4) MAC Keyboard.pdf" file are out of date and instruct you to select an icon entitled "International" which might apply to Mac OSX 10.5 or something earlier).
    • Click the "Input Sources" tab (Note: As of this posting, the included instructions in the "IPA Unicode 5.1 (v1.4) MAC Keyboard.pdf" file are again out of date and instruct you to select the "Input" tab which again might apply to an earlier version of Mac OSX).
    • Scroll down to find "IPA Unicode 5.1(v1.4) MAC" and click the box on its left.
    • If you hadn't already selected another international keyboard, you will now see a new icon in your upper right menu bar area (a national flag of sorts). Click on the flag to pop down a list of enabled key layouts to change between keyboards.
  • Notes − README
    • Changing to the keyboard layout to IPA will not automatically switch you into the correct font (since there could still be many to choose from). You will also have to select the DoulosSIL font within your application as well − which must be installed in step 3.
    • In the future now, once multiple keyboards have been made available, make sure you have the correct keyboard enabled during other activities so that you don't get weird behaviors in your apps and font situations. For the most part, it won't be a big deal if you have the wrong keyboard layout selected. But, I've made my disclaimer − personal experiences may vary.

3) Install the DoulosSIL font suite (which works with the keyboard layout given in these instructions)

  • Retrieve the DoulosSIL IPA font
    • To download the font immediately right from this page
    • To navigate to the original web pages (in case you would like to find other alternatives and options along your way, or in case there might be a newer update)
      • Navigate in your browser to DoulosSIL font.
      • Scroll down to the subheading "Font Download" (about 1 and ½ screen pages worth).
      • Scroll just a little further to the sub-subheading "Doulos SIL 4.106 (official release)".
      • Just below that sub-subheading are various download options under the title "Doulos SIL".
      • Click on hotlink "Download "DoulosSIL4.106.zip"" which downloads your downloads folder.
  • Install the DoulosSIL IPA font
    • Open your downloads directory, navigate to the DoulosSIL folder.
    • Double-click the file "DoulosSILR.ttf" thats within the DoulosSIL folder This will open your pre-installed application called Font Book and open a window that gives you the choice to "Install Font".
    • Click "Install Font".
    • Close Font Book application.
  • Notes − README
    • While your text editing applications may now see the font, getting at the "funny IPA" characters will still be difficult unless the keyboard layout is installed as well (see step 1) − just in case you skipped around in the order of your installation :).
    • Text editing applications may need to be closed and restarted in order to see the freshly installed font.
    • See the SIL.org web pages to read up on Known issues.
    • Various fonts and tools on the www.sil.org site have licenses. Individual users are responsible for how they use such freely offered resources referenced in this article as terms may change or be updated from time to time.

Using the IPA keyboard layout and font

  • Once these 3 steps are completed switching back and forth is as simple as two mouse-clicks (well, maybe only one mouse-click!)
    • Click one − change keyboard layouts from the flag in the upper right corner of your screen.
    • Click two − change to the DoulosSIL font in your editing application.
  • Note: As mentioned above in the keyboard layout installation instruction notes, you should be able to use the IPA keyboard to do normal typing in for your English (USA) needs and not have to keep swapping between layouts. You will have to swap fonts as you need to however. Other notes:
  • For a current list of compatible apps and their quirks.
  • Main page for the DoulosSIL font.
  • Fonts in Cyberspace (lots of other fonts for use).

Feedback please!

  • Found a typo?
  • Have a better way to communicate these steps?
  • Want to offer your experiences with other versions of operating systems (including Windows, Linux)?
  • Then please either email me at: This email address is being protected from spambots. You need JavaScript enabled to view it. or create a login to this blog and enter a reply comment!

Thanks for visiting!

Under your localhost's home page (see article to find out what it might be if you don't know) create a new folder

phpinfo

In that folder create an index.php file with the content

<?php
  phpinfo();
?>

Or, just put the command phpinfo() somewhere in your existing home index.php file

Assuming:

  • You wish to use the Apache2 web server that comes with OSX 10.8
  • AND you have already started it up on your own Mac (if not, see the article Enabling Apache on OSX 10.8)
  • You don't want to clutter your mac with XAMP type environments (which I believe duplicate some of what you already have on the Mac)
  • You know how to take precautions to back up critical system files you will be editing and recover from your own oops-isms
  • You wouldn't be on this page if you didn't really want to debug php (thus you are a programmer of sorts)

Then this page:

  • Will help you get to the point of being able to debug php
  • Will show how to get the Safari browser and MacGDBp App working together
  • And will do so without installing all the XAMP stuff (since OSX Moutain Lion comes with everything you need to run as a web host in the first place).

Note: XAMP, and others like it, are great tools and offer lots of features and advantages, but its not something I've really pursued. This set of instructions follows the minimalist approach and only needs to add one application (that can easily be replaced if need be by something better some day in the future) and one browser extension (that can easily be turned off). So for some XAMP is great, for me its not my cup of tea. So, I'm not criticising it.

Outline:

  • The Apache php.ini file setup - part 1
  • Installing the MacGDBp application
  • The Apache php.ini file setup - part 2
  • The Safari Xdebug Helper extension setup

The Apache php.ini file setup - part 1

Apache2 (the implementation of Apache that comes with OSX) will read its php.ini file from the /etc directory of the boot drive then run it in /private/etc

If you've never made any adjustments to the php.ini file, then it probably doesn't exist and Apache2 is running default settings (from /etc/php.ini.default). Don't mess with this one - you may need it if you have an oops-ism moment. Instead, copy it to /etc/php.ini. Here's an example of how to do so using the Terminal application (assumed for the rest of the article unless otherwise noted). Note: the background color of text on this page is slightly different for each distinct editor/mode. Note: The command sudo to "do something as super user" and may ask you for the administrator password in order for it to continue.

sudo cp /etc/php.ini.default /etc/php.ini

If instead /etc/php.ini already exists, make a backup copy of it

sudo cp /etc/php.ini php.ini.bu_yyyymmdd

{Name the backup copy anything you want - in this example yyyy is the year, mm the month, and dd the day of the month}

Now edit the php.ini file to turn on Xdebug etc.

sudo vi /etc/php.ini

If prompted for a password, enter the administrator password for your Mac (typically your own login password by default if you are the owner/administrator - otherwise, if you are using someone else's Mac, you will need to get them to assist)

Now using vi as the editor, execute the following commands.

First, find the zend extension setting by using vi (the slash in the next command does just that):

/zend_ext

which should land your cursor on this line...

;zend_extension="/usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so"

If the semi-colon (;) is still there, make sure the cursor is over it and type

x

to delete it.

If the vi editor complains that you are editing a readonly file, ignore it, will take care of that later

Next, search for the Xdebug setting by typing

/xdebug.rem

which should land your cursor on this line...

xdebug.remote_enable=1

If the (;) is till there, make sure the cursor is over it and type

x

to delete it.

Next, force save the file.

:write!

Then, quit the vi editor

:q

Restart Apache

sudo apachectl stop
sudo apachectl start

Assuming you have:

then entering the url localhost in your browser will produce a whole lot of phpinfo output which contains the following near the bottom:

Installing MacGDBp

Download Blue Static MacGDBp (assuming version 1.5 or greater)

Install MacGDBp and then run it. If your system complains because you have your security settings set such that you aren't allowing yourself to run "non app-store" apps, then you will have to change the settings in your System Prefereneces - Security pane to get it to run the first time. After you run MacGDBp, you can set your security settings back to be more restrictive once again.

The Apache php.ini file setup - part 2

Now that Xdebug has been shown to be enabled, lets now get it ready to run under MacGDBp

First, you need to know the exact url of your localhost. It can be your IP address (which may change from time to time if you are using DHCP on your network to assign you an IP dynamically). It's best if you open your System Preference application, open the "Sharing" pane

and denote your Mac's local network network name from beneath the Computer's name - is should be something.local. You will need it in just a moment

Open the php.ini file again

sudo vi /etc/php.ini

Search for the debug stuff again by typing in vi

/xdebug.rem

With your cursor on this line, enter additional lines by typing in vi

o

which opens up a new line and will put you in "insert" mode - so what you type now will be added verbatim (except for the value "localhost") until you type ESC. The value localhost in this next line needs to be replaced with your actual local hosts name (the something.local you just fetched from the Systems Preferences - Sharing pane)

xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_autostart=1

Type the ESC key to exit the vi editor

Use your cursor keys (or search mode in vi using the / as in above commands) to find the line

;xdebug.idekey="macgdbp"

Remove the ; from the beginning of the line by typeing the x over it like before.

Next, force save the file

:write!

Then quit the vi editor

:q

Restart Apache again

sudo apachectl stop
sudo apachectl start

The Safari Xdebug Helper extension setup

In Safari, install the extension Xdebug Helper by using the Safari menu "Safari : Safari Extensions...", or by going to http://extensions.apple.com, click on the "Developer" category to narrow down the search, and find Xdebug Helper

Click the Install button to its right.

Once the installation completes a new icon will appear to the left of the URL box in Safari

Now setup the Xdebug Helper extension in the Safari Preferences window under its Extensions tab. Change the IDE key: field to read XDEBUG_macgdbp

Close the Extensions window.

You will need to navigate to a site for which Safari has full access to the php - such as your localhost (ISP provided web sites run the php for you so you don't have access to its php scripting and only see the results of such in your browser).

Navigate to your localhost home page in Safari.

Now, to see it in action, popdown the menu from the Xdebug Helper icon at the top of the Safari window, and select "Trace"

It should now show a banner number over the icon to show how many sessions are active

Refresh your localhost home page in Safari

MacGDBp should now be showing you a trace event!

Keep in mind you have now interrupted the refresh of the page! You must go to the main window of MacGDBp and operate its buttons - Step, Continue, whatever. To stop debugging, go back to the XDebug Helper icon on Safari and set it to Disable.

 

 

Some history:

Prior versions of OSX made it difficult to use Xdebug with the Apache web server that was included with the system. That seems to have changed with Mountain Lion (OSX 10.8)

 

Other useful links and credits:

 

Feedback is always welcome from non-spammers: feedback

 

Subcategories

Tips and Tos on Mac OSx

Tips and Tos on existing OSX apps

Tips and Tos on Joomla

Tips and Tos on Wordpress

Specific how to, tips for Internet Service Providers