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.

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

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀