Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I locally debug Facebook PHP applications?

I'm using Zend debugger and PDT for PHP development and have run into an issue debugging Facebook PHP. I'm using the example.php in the SDK to test. The application runs fine from Facebook, but I'm having trouble setting breakpoints. I have tried:

  1. Run from Eclipse - Application does not run as expected. I'm getting null values for $_SERVER['HTTP_HOST'] and $_SERVER['REQUEST_URI'] although I can set breakpoints and debug.

  2. Run from Facebook - the application runs as expected, but ignores breakpoints.

I'm using DynDNS for my DNS lookup and have changed my host file to redirect the URL to my local host.

I'm not even sure if #1 is possible, but it would be nice to use Eclipse and not have to refresh a web page as in #2. Any ideas?

like image 286
David Broadhurst Avatar asked Feb 23 '26 13:02

David Broadhurst


1 Answers

Try defining a local domain for your local server in the hosts file of your OS (in Windows you can find it in C:\Windows\System32\drivers\etc).

For example, if your server runs on localhost, add the row:

local.mydomain.com 127.0.0.1

On the Facebook developers site (in your application settings), set the domain of the application to mydomain.com of local.mydomain.com and for the canvas URL (if you work within facebook canvas) set the local URL of your application.

For example:

Canvas URL: http://local.mydomain.com/my_application/index.php

Last, change the Debug URL of the specific page (in Eclipse's menu Run* → Debug Configuration) to the URL of the canvas (for example, http://apps.facebook.com/my_fb_app/).

like image 79
Yaron U. Avatar answered Feb 25 '26 03:02

Yaron U.