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

如何在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.

    已采纳该答案
    打赏 评论

相关推荐 更多相似问题