微信小程序访问php后台可以触发xdebug

为了方便让微信小程序访问php后台可以触发xdebug的调试:
对比了一下chrome浏览器(已添加xdebug的插件后)中开启debug和未开启debug调试发起的http包的请求头。


Cookie:thinkphp_show_page_trace=0|4; PHPSESSID=v6iss15rgjq73re893ho6gbll1; 
  _ga=GA1.2.789354616.1512467762; thinkphp_show_page_trace=0|0; backend_list_rows=10; 
  Hm_lvt_d740981d25ee4b445e195a1e4a37630b=1512467763; Hm_lpvt_d740981d25ee4b445e195a1e4a37630b=1513818408

Cookie:thinkphp_show_page_trace=0|4; PHPSESSID=v6iss15rgjq73re893ho6gbll1;
  _ga=GA1.2.789354616.1512467762; XDEBUG_SESSION=XDEBUG_ECLIPSE; thinkphp_show_page_trace=0|0; backend_list_rows=10; 
  Hm_lvt_d740981d25ee4b445e195a1e4a37630b=1512467763; Hm_lpvt_d740981d25ee4b445e195a1e4a37630b=1513818408



可以发现cookie域多了一个key-value。将此添加到微信小程序中发起请求的Headers就可以触发调试了。

比如:

 function doRequest() {
    var authHeader = buildAuthHeader(session.get());
    wx.request(utils.extend({}, options, {
      header: utils.extend({ cookie:'XDEBUG_SESSION' }, originHeader, authHeader),
      method: method,
      success: function (response) {
        var data = response.data;
        if (data.status == constants.API_SERVER_EXPIRE_CODE) {
          doRequestWithLogin();
        } else if (data.status == constants.API_USER_NOT_AUTH_CODE) {
          wx.navigateTo({
            url: '/pages/auth/auth',
          })
        } else {
          callSuccess.apply(null, arguments);
        }
      },
      fail: callFail,
      complete: noop,
    }));
  };

猜你喜欢

转载自blog.csdn.net/qq_20745827/article/details/78859663