I've setup Xdebug on a local Vagrant instance running Ubuntu. It works as expected and I can setup breakpoints in my application.
I have a scenario where the application makes a request to an internal API. The internal API is on the same server and same codebase.
Tree illustration
codebase/
app/
root
api/
root
The application is accessible as https://local.myapplication.com and the API is accessible locally as http://local.api.myapplication.com).
If I now set a breakpoint in some code for the API and then visit https://local.myapplication.com/some/action/that/triggers/the/api/code the breakpoint is only triggered if I do not initialise the Xdebug session for the first application, i.e., I do not set the XDEBUG_SESSION_START
query parameter. If it's set, my breakpoint is ignored.
There is a certain drawback to this. If I have a breakpoint in the application and the API, I can't trigger both at the moment. Either I can trigger the application breakpoints or the API breakpoints.
I'm using Sublime Text 3 with the plugin https://github.com/martomo/SublimeTextXdebug. My Xdebug settings in php.ini
are:
zend_extension="/usr/lib/php5/20090626/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_host=192.168.3.1
xdebug.remote_port=9000
xdebug.remote_log="/tmp/php5-xdebug.log"
Is this fixable? Any answers/comments are appreciated!
Two choices. If the first (easier) doesn't work the second surely will.
In php.ini, add the following to your xdebug settings:
xdebug.remote_autostart = 1
See documentation here
You'll need to have two separate instances of your IDE/text editor listening to xdebug - each on a different port. You can set both instances to edit the same project while their xdebug service listens on different ports.
For example:
To make your "internal API" run xdebug on port 9001, you can simply do the following at the start of your "internal API" script:
ini_set('xdebug.remote_port', '9001');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With