Enable xDebug for a webhook - php

I know that xDebug can be enabled (if configured so) to be enabled when a certain cookie is sent along.
I have the case now that a PHP script is being called through a remote server (webhook). Is it possible to enable xDebug through a PHP function call that I can place at the beginning of the PHP file to be called by the webhook?
Or is there any other possibility to enable xDebug for that webhook?

Okay, figured something out.
One can simply append the GET parameter "XDEBUG_SESSION_START" to the URL being called by the webhook to enable xDebug.

Alternatively, assuming you're running Xdebug 3 (which you most likely will be in 2023), and you have access to the xdebug configuration, you can enable start_with_request.
In my setup (IndigoStack) the file is at conf.d/20-xdebug.ini. You need to add the following line:
xdebug.start_with_request=yes
Read more here: https://xdebug.org/docs/upgrade_guide

Related

How to debug PHP with Xdebug 3.1.5 to a remote server without php.ini access

I'm trying to use Xdebug 3.1.5 that is installed on the server to be able to see the stack trace, but I'm not able to connect / see any debugging info.
I tried following several instructions online to SSH into the server with commands like ssh -R 9003:localhost:9003 username#username.com, but still had no luck.
I locally enabled using all / a combination of these settings to override the php.ini:
//error_reporting(E_ALL);
//ini_set('xdebug.mode', 'develop,debug');
//ini_set('xdebug.client_port', '9003');
//ini_set('xdebug.start_with_request', 'trigger');
//ini_set('xdebug.discover_client_host', true);
//ini_set('xdebug.client_host', 'localhost'); // I also tried switching this with my own IP
//ini_set('xdebug.show_error_trace', 1);
Still no luck even after locally overriding with SSH. Any insight would be appreciated!
You don't need to make any settings to see Xdebug's stack traces.
That comes automatically with the default setting of xdebug.mode=develop.
You don't need to do anything with clients, etc.
If you need debugging, than your SSH command is needed, but you need to be able to change the php.ini file to enabled debug mode with xdebug.mode=debug. If you can't change your php.ini file, then you can't change Xdebug's modes.

enable curl in xampp, windows

trying to enable curl in xampp 3.0.12 in windows environment.
Updated the php.ini in the php folder to enable curl, and there is no php.ini file in the apache/bin folder.
phpinfo() says:
loaded configuration file: C:\xampp\php\php.ini
curl support:enbaled
curl information: 7.24.0
and when i try to run a http_get() command php says:
Fatal error: Call to undefined function http_get()
Restarted both windows and xampp several times to update the changes.
Would be grateful for some advice, as I searched through similar topics on the web but can't get any further.
Note that the function http_get() belongs to the pecl http extension and not to the curl extension. Refer to the documentation of the curl extension to learn how you can use it to retrieve documents via http. You'll also find a lot of posts on stackoverflow
Also note, that the function file_get_contents() can be used to get documents over http in a very simple way. Although it is limited it will fit in much cases. To retrieve a page you can issue:
file_get_contents('http://www.server.com/page.html');

Namespace of curl in symfony2

What is the name space of curl in symfony2? It gives Fatal error: Call to undefined function curl_init()
It would seem that curl support is not enabled - check your php.ini
PHP invoke CURL with simple functions. If you have enabled the 'php_curl' extension in your php.ini, you should have no trouble invoking curl normally. But for certain configurations of PHP (I don't remember what) I was advised to use backslash before [like \curl_init();]
There are two php.ini files for bowser and for console. Make sure that you have enabled php_curl in both. This happened to me when developing a console script. This must work for sure.

How to debug using WAMP?

I just installed WAMP on Windows XP. I have a simple PHP file that is crashing. I ran it from command line using php test.php.
What is the best way to debug php files? How do I display debugging info?
I looked at php.ini and it includes display_errors = On. Does this do anything?
I tried turning on XDebug from the PHP WAMP menu. This doesn't seem to do anything, besides restarting the server. Do I need to use this? How?
Thanks.
You can look at the log at c:/wamp/logs/php_error.log. If you are not sure whether your PHP log is being redirected here, check your php.ini file and search for a line like this:
;error_log = "c:/wamp/logs/php_error.log"
You may want to remove the comment on this line.
As much as i know about PHP and WAMP.I don't think there is any special debugging option available in this.for the debugging you need to print the answer using echo and exit function wherever in your code you feel the error may posible. The other option is, you need to use software which provide debugging facility such as eclipse with php.
I am using WAMPSERVER 2.4 on Windows 8 pro. I was using WAMP on localhost.
It appears that in my version of WAMP, the php.ini file had appeared as:
;error_log = "Z:/wamp/logs/php_error.log"
When in actuality,for me get the function error_log() to work properly, I wanted it to appear as :
error_log = "Z:/wamp/logs/php_error.log"

Can't get XDebug to make a connection in Vim. Getting "no attribue 'stop'" error

Judging by how many search engine hits this error message generates, I know this is a common problem, yet there aren't any helpful answers out there.
I'm trying to setup XDebug in Vim using Sam Ghods Debugger.vim script while following the instructions on How to Debug PHP with Vim and XDebug on Linux (which is a commonly referenced source on getting Vim setup with XDebug). I'm running MacVim 7.3 on OSX 10.6 and when I try to connect the debugger to the server, I get:
(<type 'exceptions.AttributeError'>, AttributeError("DbgProtocol instance has no attribute 'stop'",), <traceback object at 0x104595680>)
File "/Users/tjlahr/.vim/plugin/debugger.py", line 1078, in debugger_run
debugger.run()
File "/Users/tjlahr/.vim/plugin/debugger.py", line 928, in run
self.protocol.accept()
File "/Users/tjlahr/.vim/plugin/debugger.py", line 560, in accept
self.stop()
Does anybody have experience troubleshooting this error?
Please note that I'm not debugging over port 9000 because it seems it might conflict with fastcgi enabled in PHP. So I'm debugging over port 9001 and have changed by settings in php.ini and the g:debuggerPort variable respectively.
Thanks for your help.
I think I got it!
Can you try installing this Vim Plugin:
http://www.vim.org/scripts/script.php?script_id=2508
It seems that "AttributeError("DbgProtocol instance has no attribute 'stop'",)" is a general error.
I just installed XDebug and the debugger.vim plugin and ended up receiving this message. My problem was that remote debugging was not enabled. Build a phpinfo file:
<?php
phpinfo();
?>
somewhere in your web server directory, and check over all your xdebug configuration variables, which should be listed near the bottom of the page. On my system with xdebug-v2.2.0-dev built from the GitHub repo, xdebug.remote_enable was set to false. Pasting that at the bottom of your php.ini file and setting it's value to 1 enabled clients to connect to the xdebug session.
Also, in the xdebug source there is a directory called "debugclient", which can be used to test any connection problems. Follow the instructions in the INSTALL file in it's directory to build it.
And, one last thought, after you run the plugin script in VIM, you need to refresh the webpage you are trying to debug within 5 seconds, or else the script, acting as a client, will timeout.

Categories