Testing PHP locally in Flash using Mac OS X Leopard

I was working on a project that uses PHP to generate a directory listing of images for use in a Flash slideshow. After working on it for a bit, I realized how annoying it was to have to keep uploading the files to a server every time I wanted to test it. I knew OS X runs an Apache web server that allows you to host content on your network. However, if you try to test a PHP file it won’t work. I discovered that PHP is actually already installed, however it is not enabled by default. I found a site that gives clear step by step instructions for getting PHP up and running:  Click here for the instructions.
It involves a bit of Terminal scripting but is pretty straightforward. As the article suggests, you will need to download a text editor that allows you to edit hidden files. They suggest Text Wrangler, which I found to be very easy to use. So just follow your instructions and you will have PHP up and running locally- very handy (don’t forget to enable Web Sharing under the Sharing System Preferences Panel or toggle it off and on if it is already running).
1) I had issues trying to test files under the admin user I was logged in as. A simple solution is to create a new user and use that for testing. I named mine “test”, so it would be accessed at “http://localhost/~test/.”
2) Also, when you are testing your PHP locally within your Flash movie, you will need to use the absolute path i.e. “http://localhost/~test/myFile.php”. Once it is ready for production, change the path to relative i.e. “myFile.php”.

About Curious Minds
We are a web development firm in New York and Chicago, providing development resources and consulting for websites and mobile apps since 2004.