Sunday, November 8, 2009

XAMPP and Facebook

Ah yes, this is the perfect example of why XAMPP is so god-damned great: A few days ago yours truly, was intrigued by the buzz around Facebook and its application framework. After some light reading, what seemed like a long and perilous road became a surprisingly short exercise in flipping a few switches and copy/pasting past it all to get a taste of what it feels like to be a Facebook Application Developer.

Here's the breakdown:
  1. Get a Facebook account and login to it.
  2. Add Facebook's Developer application to your profile.
  3. Go through the motions of creating an application with Facebook which is really nothing more than a registration process of sorts.
  4. If you understand the Anatomy of a Facebook Application then you know that the two most important components for creating/registering an application in/with Facebook are:
    1. Callback Url
    2. Canvas Page URL
  5. Get XAMPP. (I know the site looks shady but I'm not their UI guy.)
  6. If you don't have a domain name, simply login to your home router and figure out your real IP address.
  7. Edit your router's Port Forwarding settings to allow connections from the outside world to come in to your computer at port 80.
  8. Startup Apache from your XAMPP install and perform a quick sanity test to see if you can access the default web site.
  9. Take the source for a default index.php page provided by Facebook and throw it onto your machine and point your Apache's httpd.conf file to it. Also throw down 3 more PHP files that make up the Facebook client libraries.
blah blah blah

XAMPP Basics

XAMPP is a great package to have for complete newbies in order to learn PHP-based website development. In one simple installation you can lay down the Apache Web Server, MySQL, PHP, Perl, phpMyAdmin etc. (an impressive list).

This blog, more than anything, is a narration of how one developer went and wrapped his head around what all XAMPP has to offer. If this helps you "ramp-up" as well ... then great!

1) What's a good place to install XAMPP?
As a rule of thumb, always choose a path without spaces and keep it short and simple, for example: C:\apps\xampp\ would be a good location.

2) After an install what should my directory structure look like for easy access?
Trust me on this, you never ever want a structure such as C:\apps\xampp\xampp\ ... why you ask? Because it annoys me. In my opinion, the following default layout of XAMPP is ideal:
C:\apps\xampp\apache
C:\apps\xampp\phpMyAdmin


3) I know that Apache (part of the XAMPP bundle) uses the httpd.conf file to control what's hosted and what isn't. Then why can I not find any mention of apps such as phpMyAdmin in this file, even though I can clearly see them hosted at locations such as http://localhost/phpmyadmin/ etc.?
Technology or at least technology done well ... is all about making your product/components intuitive. A closer look at the httpd.conf file reveals some interesting information:

It becomes clearer that not all the information needs to be seated in the httpd.conf file, rather there are other files that have been laid down as part of the XAMPP installation which contain useful configuration information. In this case, we find that a file named httpd-xampp.conf has what we are looking for.

4) What's a good place to start tinkering?
Well I found the following article by Dalibor Dvorski to be extremely helpful, so I would suggest starting there.

5) What's the author of this article currently looking to master about XAMPP?
I'm aiming to tryout the following article next, in order to see if I can add a lilttle something extra to my knowledge of XAMPP.

Running the Derby-Network-Service

Since Derby is all about having a file-like database on your hard-drive, its generally a good idea to have one location on you development machine of choice, where you can place a derbynet folder for all your derby network access needs.

For example:
  • c:\apps\derbynet (win flavor)
  • /opt/derbynet ('nix flavor)
Ok! But what should this general purpose folder contain? The files in this folder should be the ones from Derby's lib package. You can also create something along the lines of the following files as the start and stop commands under the derbynet folder:
  • startDerbyNet.sh could contain the following lines:
    • export CLASSPATH=/path/to/derby.jar:/path/to/derbytools.jar:/path/to/derbynet.jar:$CLASSPATH
    • java org.apache.derby.drda.NetworkServerControl start -h -p 1527
  • stopDerbyNet.sh could contain the following lines:
    • export CLASSPATH=/path/to/derby.jar:/path/to/derbytools.jar:/path/to/derbynet.jar:$CLASSPATH
    • java org.apache.derby.drda.NetworkServerControl shutdown -h -p 1527
And then you can call upon these scripts like so:
  • /opt/derbynet/startDerbyNet.sh > derbynet.logs &
  • /opt/derbynet/stopDerbyNet.sh