dsw1608 2015-10-20 16:16
浏览 34
已采纳

如何在MS Azure中调试PHP

First things first: I was given the task to deploy a Drupal website on Azure.

Locally I use OS X running Apache and everything works ok. When I deploy the project to Azure, I get an error. After some debugging I isolated the error to this snippet of code:

private function getToken(){
    $ch = curl_init($this->host . $this->clientId . "&client_secret=" . $this->clientSecret);
    curl_setopt($ch,  CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',));
    $response = json_decode(curl_exec($ch));
    curl_close($ch);
    $token = $response->access_token;
    dvm($response, $name = NULL);
    return $token;
}

dvm() is a Drupal Devel function, but suffice to say that's sort of print_r for Drupal on steroids.

The problem I'm getting is that for whatever reason, $result is coming back NULL. When I run the same code on my local machine and on a Linux/Debian box, all worked as expected (I get an Object as a result of the curl).

This leads to the conclusion that Azure is not liking something in this piece code. The problem is finding out what. Any ideas?

  • 写回答

1条回答 默认 最新

  • douganggu4392 2015-10-22 08:51
    关注

    For a prod environment, display_errors is set off in PHP runtime on Azure Web Apps. We can open the setting for debugging via change the build-in PHP configurations.

    Here are simple steps:

    1, Add a .user.ini file to your root directory.

    2, Add configuration settings to the .user.ini file using the same syntax you would use in a php.ini file. With your demand, your .user.ini file would contain this text:

    display_errors = On

    3, Deploy your web app.

    4, Restart the web app.

    You can read official guide for more information.

    Furthermore, we can login in the Kudu console of our websites to manage our sites. The URL of Kudu console should be like: https://{your_web_site_name}. scm.azurewebsites.net, and click Tools => Diagnostic dump to download the diagnostic logs.

    Additional, we can use WebMatrix to directly modify your code on Azure Web Apps.

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

报告相同问题?

悬赏问题

  • ¥50 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?