Freitag, 20. November 2015

[PHP+GDB] Debugging in PHP Part 2

I found a little thing called Pyclewn which is "A Vim front-end to the gdb and pdb debuggers." With a good configured Vim it is for me much easier and nicer to debug then with plain gdb.

Installing Pyclewn is easy. Doing the "Quick start" was enough on my machine:

What you need to do is nearly the same as doing it in gdb. First you start Vim. In there you start Pyclewn with thing to debug, like so:
:Pyclewn gdb --args php5 -e soap_test_client.php
To start gdb use ':Cecho'. Or start the debug-run with ':Crun'. Or insert breakpoints or do other stuff. Afaik most gdb-commands are found prepending the C, like Cecho, Crun, Cbreak, etc.
For me the important commands were:
:Cbreak -- set a breakpoint
:Crun -- start running the program
:Ccontinue -- continue from the current point
:Cnext -- go to next line
:Cstep -- step inside current line
:Cfinish -- finish current function and return
:Ckill -- stop the running program
:Cinfo breakpoints -- show set breakpoints
:Clist *$pc -- show current line (line where program counter is)
:Cdelete -- delete all breakpoints
:Chelp -- get help
Pyclewn stopped at breakpoint and printing content

And finally I also found the bug that was causing errors on loading my WSDL in PHP SOAP:
a / at the end of an URI
In the PHP source code in ext/soap/php_encoding.h are strings defined for namespaces, prefixes and so on. It seams that most of them I had done right. But this one little thing, the soap-http, I had a / at the URI and PHP just wanted the string without it.

'soap-http': ""
So, if you're getting a SOAP-ERROR on parsing WSDL in PHP, be sure to check if the namespaces are the same.