dsa122870 2014-05-15 16:17
浏览 70
已采纳

Xdebug与当地api使用vagrant

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)

  • 写回答

1条回答 默认 最新

  • dongpengqin3898 2014-05-16 14:41
    关注

    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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试