Last active
December 14, 2018 21:58
-
-
Save igoralves1/4a76dc5860d3f11526d68bff0afe0951 to your computer and use it in GitHub Desktop.
How to debug php-xdebug x NetBeans8.2 x POSTman in an external income request by POST?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #http://stackoverflow.com/questions/1531391/launch-xdebug-in-netbeans-on-an-external-request | |
| #https://xdebug.org/docs/all_settings | |
| #HTTP Debug Sessions -> https://xdebug.org/docs/remote#browser_session | |
| Attach the debugger to any request that comes in, rather just those I launch from within Netbeans? | |
| xdebug.remote_autostart | |
| Type: boolean, Default value: 0 | |
| Normally you need to use a specific HTTP GET/POST variable to start remote debugging (see Remote Debugging). | |
| When this setting is set to 1, Xdebug will always attempt to start a remote debugging session and try to | |
| connect to a client, even if the GET/POST/COOKIE variable was not present. | |
| HTTP Debug Sessions -> https://xdebug.org/docs/remote#browser_session | |
| xdebug.remote_enable | |
| Type: boolean, Default value: 0 | |
| This switch controls whether Xdebug should try to contact a debug client which is listening on the host | |
| and port as set with the settings xdebug.remote_host and xdebug.remote_port. If a connection can not be | |
| established the script will just continue as if this setting was 0. | |
| ============= Solution ============================= | |
| 0 - Set the php.ini with variables that will prepare netBeans to listen incoming request | |
| This is what I have in my php.ini | |
| [xdebug] | |
| ;zend_extension ="c:/wamp64/bin/php/php5.6.25/zend_ext/php_xdebug-2.4.1-5.6-vc11-x86_64.dll" | |
| zend_extension = c:/wamp64/bin/php/php5.6.25/extphp_xdebug-2.5.3-5.6-vc11-x86_64.dll | |
| ;xdebug.remote_enable=1 | |
| ;xdebug.remote_handler=dbgp | |
| ;xdebug.remote_host=localhost | |
| ;xdebug.remote_port=9000 | |
| ;xdebug.profiler_enable = off | |
| ;xdebug.profiler_enable_trigger = off | |
| ;xdebug.profiler_output_name = cachegrind.out.%t.%p | |
| ;xdebug.profiler_output_dir ="c:/wamp64/tmp" | |
| ;xdebug.show_local_vars=0 | |
| ===> xdebug.remote_autostart=on | |
| ===> xdebug.remote_enable=on | |
| ===> xdebug.remote_enable=1 | |
| xdebug.remote_handler="dbgp" | |
| ;xdebug.remote_host="localhost:81" | |
| xdebug.remote_host=localhost | |
| ;xdebug.remote_connect_back=1 | |
| xdebug.remote_port=9000 | |
| xdebug.remote_mode=req | |
| ===> xdebug.idekey="netbeans-xdebug" | |
| 1 - Put the break-points (xdebug_break();) into the debuged page that will receive the income request trough POST. | |
| 1.1 - Go to project properties > run configuration > advanced > debug url and check do not open web browser (*). | |
| Do not set the host under debugger proxy. Save. | |
| 2 - Start a debug process in NetBeans => rigth click over the project name and choose Debug | |
| 2 - At the botton in the NetBeans window we will see "Waiting for connection (netbeans-xdebug) ..." | |
| 3 - Open POSTman APP and set the body with the information that will be sent through the request HTTP POST. | |
| That can be a XML or JSON or fields from a form. | |
| 4 - Inside the field URL "Enter request URL" put the address whit the variable XDEBUG_SESSION_START to a value netbeans-xdebug | |
| http://mySite.com/postback.php?XDEBUG_SESSION_START=netbeans-xdebug&id=12345&invoiceID=AB_1234&hash=AgQ65uj12%3D&varN=valN | |
| 5 - Hit send button in POSTman and we will see the beggining of a debug session in NetBeans. It should stop at | |
| the first line as my netBenas is configured to do. | |
| 6 - We can follow the regular process. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank!!!! it work form me!!!!