How can I locally debug Facebook PHP applications? - php

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:
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.
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?

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/).

Related

how to debug local php application running on WAMP server exposed publicly via ngrok using visual studio code?

I am trying to test my dialogflow fulfilment webhook(which needs to be publicly accessible) PHP endpoint. I am using WAMP server and visual studio code as IDE to run my PHP application on my local and made it publicly accessible using ngrok. Using localhost URL, I am able to debug the application using xdebug extension. But when I use the ngrok URL, I am able to access it perfectly but I am not able to debug it. I have tried to follow this link :
https://hajekj.net/2016/09/06/remotely-debugging-php-on-azure-web-apps-with-ngrok/ , but it is using TCP endpoint, whereas I need an https endpoint. How can I debug in this case?
When we use ngrok tunnelling, doesn't it finally route all the requests we receive to localhost? Because I am getting the desired results, but not able to debug.

IIS site will not load

I am running a site on my home computer with IIS 10.0. I have already set the permissions to full-control (more specifically, I set IIS_IUSRS to Full control).
However, when I run the site (by right-clicking it and hitting Manage Website --> Browse), I get an empty loading page. It keeps loading and never finishes, and doesn't show any errors. My site is very simple (basically a hello world site).
My site is made with php. I have tried these URLs: localhost, localhost:80 (the port number), localhost/index.php, and localhost:80/index.php. None of them work.
I also have another php site that I hosted with IIS 10.0 and it works.
Why does this happen? How do I fix it?
Some more details:
Anonymous Authentication is enabled and set to Application pool identity
ASP.NET Impersonation is disabled
The site has a config file

PHP Desktop Not responding on AJAX CALL

I am trying to convert my existing website into PHP Desktop Application using PHP Desktop, everything is working fine but when i am trying to login i am using ajax call for login it does not responding. it does not even print any error message on php desktop console.
It might be that your ajax code is making a request to http://127.0.0.1/some_resource, but phpdesktop web server is running at http://127.0.0.1:1673/ - as you can see in your console logs. PHP Desktop assigns a random web port to avoid conflicts with existing software. In a php script you can know the port by checking $_SERVER variable. If you want to set a fixed web server port then you can do so by editing settings.json file (see the Settings wiki page in phpdesktop project).
You have to check your ajax code to know what url it is trying to access, you can do this using Developer Tools window, you can open it in phpdesktop using mouse context menu.
You don't really have to set fixed web port if you can modify your ajax code to not use full paths with domain names and just the path like "/some_resource".

XAMPP-Project not working on different computers

So, I Have REST URL to register like this :
http://localhost:8080/task_manager/v1/register
And then, I try the URL in Google Chrome Advanced Rest Client.
Everything goes smoothly.
And now I decided to test the URL on another computer.
So I copy paste the file to another computer and test the URL once again.
But the result is I got 404 ERROR, Object not found.
Did I hit something wrong ?
I copy all the file correctly.
This is weird.
UPDATE : I use all the folder which contains all the files and I using same version of XAMPP & PHP on that both computers
Localhost targets on your computer, means the actual machine the files are on. If you are using php > 5.3 you can use php's build in development server with
php -S __YOUR LOCAL IP__ : 8000
and access the site from all the computers within your network
For example, if you run
php -S 192.168.0.1:8000
on your development machine, you can access it via
http://192.168.0.1:8000/
from every device connected to your local network
As you have written in your comment you have copied all the files, it is most likely that you either don't have php, apache or a webserver (MAMP,WAMP,...) installed (or started) on the other machine, or you just didn't copy the files to the correct folder.
an url beginning with localhost refers to the computer where it's called from. See wikipedia localhost.
To provide the same behavior on another computer you need to copy the whole project and install the used server software e.g. apache, mysql etc. pp. or access the project from another computer in the same network using the internal network IP instead of localhost.
FYI: localhost is almost the same like the loop-IP 127.0.0.127
so on the computer where it works there should also work: http://127.0.0.127:8080/task_manager/v1/register
Now replace the 127.0.0.127 with the IP of your computer when testing it on another computer
You need to run your project on a webserver like your local.

PDT XDebug. How to debug with ip address but not localhost

I am developing a PHP project and using PDT with XDebug which is working smoothly at localhost. (By the way, I am using XAMPP in windows 7)
Now, I want to debug some of the features from other PCs which need to use my local IP(or pc name) for request.
But I even can not debug at my local PC with IP address that is like http://127.0.0.1/xxx or http://192.168.1.yyy/xxx.
I have looked up some articles which introduced to change some settings in the php.ini and httpd.conf files. But there is no help to me (I have done some of them at the begining of I setting up the project and without problem to use localhost).
What I did is that first launch one browser (ie, ff, safari, etc.),
and enter the url I want to debug(of course there is no any response at this time)
Then I add ?XDEBUG_SESSION_START=ECLIPSE_DBGP just behind the url.
Secondly I launch another browser and enter the url I want to debug again,
but this time, you will have the PDT been going into debug mode.
Soruce: http://devzone.zend.com/1147/debugging-php-applications-with-xdebug/
by searching XDEBUG_SESSION_START which gave me the hint.

Categories