0

I have xdebug working locally for 'normal' sites (I am using google chrome with xdebug helper and phpstorm to talk to a site hosted on a vagrant box).

However if I try and connect to a locally hosted api site (also on a vagrant box) using a REST client (google chrome's advanced rest client plugin) it will not work.

What settings do I need for xdebug on the vagrant box, and what additional information do I need to include when making api calls?

My settings (on the vagrant machine) which work for phpstorm and vagrant box are as follows:

    ;;;;;;;;;;;;;;;;;;;;;;;;;;
    ; Added to enable Xdebug ;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;
    zend_extension="/usr/lib/php5/20100525/xdebug.so"
    xdebug.default_enable = 1
    xdebug.idekey = "vagrant"
    xdebug.remote_enable = 1
    xdebug.remote_autostart = 0
    xdebug.remote_port = 9000
    xdebug.remote_handler=dbgp
    xdebug.remote_log="/var/log/xdebug/xdebug.log"
    xdebug.remote_host=10.0.2.2 

the idekey setting connects to a user defined application on phpstorm (see here: http://www.mailbeyond.com/phpstorm-vagrant-install-xdebug-php)

14
  • And .. how do you debug "normal" sites? Please describe (in short). So far (as I understand) xdebug is missing debug marker (cookie or GET/POST parameter that tells xdebug to debug this request). In browser this cookie is added/removed by special browser extension or bookmarklet .. or GET parameter is added to URL when initiated from IDE. For API calls you will need to add such info yourself .. or configure xdebug to debug every single request. Commented May 15, 2014 at 22:21
  • For 'normal' sites I: use the settings outlined above on the vagrant machine; use google chrome's xdebug helper which send the required session start information, and configure phpstorm as outlined here mailbeyond.com/phpstorm-vagrant-install-xdebug-php by creating a 'server' and attaching it to the debug configuration (this is how xdebug.idekey = 'vagrant' talks to phpstorm) Commented May 16, 2014 at 13:16
  • I cant seem to get it working with REST client even if i include the debug marker as outlined here: stackoverflow.com/questions/19139803/… Commented May 16, 2014 at 13:18
  • 1
    You can ignore "Add Remote Server" step -- IDE will help set it up on first incoming connection. Right now it's possible that your path mappings are incorrect. Commented May 16, 2014 at 13:25
  • 1
    From what I see that file has .cache extension. If possible -- copy it to local project files (do not forget to associate .php.cache with PHP files otherwise IDE will not treat it as PHP file and will not be able to step it trough). Plus, you may need to copy it over again after each modification of important/participating files. Alternatively (the best) -- try disabling such caching. Commented May 16, 2014 at 14:18

1 Answer 1

2

Through much striving managed to fix this with the help of @LazyOne

Here are my final settings if anyone else needs help:

XDEBUG FOR API

; Enable xdebug extension module
zend_extension=xdebug.so

; see http://xdebug.org/docs/all_settings
xdebug.max_nesting_level = 250
xdebug.max_nesting_level = 250
;for ubuntu
zend_extension="/usr/lib/php5/20100525/xdebug.so"
;for centos
;zend_extension="/usr/lib64/php/modules/xdebug.so" 
xdebug.default_enable = 1
xdebug.idekey = "PHPSTORM"
xdebug.remote_enable = 1
xdebug.remote_autostart = 0
xdebug.remote_port = 9000
xdebug.remote_handler=dbgp
xdebug.remote_log="/var/log/xdebug/xdebug.log"
xdebug.remote_host=10.0.2.2

• Change symfony2 app_dev.php to:

//$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
$loader = require_once __DIR__.'/../app/autoload.php';

• May also need to put a breakpoint on the app_dev.php and try 'stepping into' the main project. This will prompt you to set up paths on the edit path mappings link: http://blog.jetbrains.com/webide/2011/02/zero-configuration-debugging-with-xdebug-and-phpstorm-2-0/

• On REST client as a header: cookie XDEBUG_SESSION=PHPSTORM

You also need to include:

?XDEBUG_SESSION_START=PHPSTORM (e.g. /courses/?XDEBUG_SESSION_START=PHPSTORM)

as a parameter if using a REST client. PHPSTORM's client will add it automatically

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.