One of the most common questions I get regarding Facebook’s new PHP SDK v4.0.x is how to set it up and get started. My previous tutorial covers how to start using the SDK, but not how to arrange your files and the SDK itself – this tutorial attempts to bridge the gap.
After downloading the latest version of the Facebook PHP SDK (currently v4.0.7), you need to extract the source code and copy them into your application folder. The best way to do this is to copy the contents of the src
folder into your application folder. The src
folder contains a single Facebook
folder with all the PHP files you need to use the SDK. You only need to copy the Facebook
folder from here.
A typical application setup can be as follows:
If you use a PHP Framework like CodeIgnitor, you should copy the Facebook folder to the /application/libraries
folder instead. For example:
Once the basic file structure is set up, you can follow the “Getting Started” tutorial to find out how to start building Facebook Apps.