drwjv28028 2018-08-31 23:21
浏览 112
已采纳

未捕获的错误:未找到类'WindowsAzure \ Common \ ServicesBuilder' - MS Azure | PHP

I have created the composer.json file in my root folder where my index.php file is presents, with the following code in it:

{
 "require": {
    "microsoft/windowsazure": "^0.5"
 }
}

and on downloading composer.phar, I have installed it using:

php composer.phar install

I'm trying to create a table and add entities to it in php. I use the command

use WindowsAzure\Common\ServicesBuilder;
$connectionString = 'DefaultEndpointsProtocol=https;AccountName=******;AccountKey=***/***************************/******************/**********************************==';
$tableRestProxy = ServicesBuilder::getInstance()->createTableService($connectionString);
try {
  // Create table.
  $tableRestProxy->createTable("mytable");
}
catch(ServiceException $e){
  $code = $e->getCode();
  $error_message = $e->getMessage();
  echo $code.": ".$error_message."<br />";
}

When I run this on local host on my Ubuntu, I get an error saying-

Uncaught Error: Class 'WindowsAzure\Common\ServicesBuilder' not found in /home/my_folder/php-docs-hello-world-master/index.php:30

If I add

require_once 'vendor/autoload.php';

before defining my $connectionString, then my error changes to:

/index.php - Uncaught RuntimeException: Error creating resource: [message] fopen(https://eyesav.table.core.windows.net/Tables): failed to open stream: Unable to find the socket transport &quot;http&quot; - did you forget to enable it when you configured PHP?

Can someone help me figure out this issue, if it is with the installation of my composer, or my connectionString, or something else?

Thanks in advance :)

展开全部

  • 写回答

1条回答 默认 最新

  • doskmc7870 2018-09-02 23:05
    关注

    Can someone help me figure out this issue, if it is with the installation of my composer, or my connectionString, or something else?

    If I use the code you mentioned, I also could reproduce the issue you mentioned.

    Please have a try to use following code to create the table client. It works for me.

     use MicrosoftAzure\Storage\Table\TableRestProxy;
     use MicrosoftAzure\Storage\Common\ServiceException;
     $tableClient = TableRestProxy::createTableService($connectionString);
    

    The following is the demo code from azure official document.

    <?php 
    require_once "vendor/autoload.php";
    use MicrosoftAzure\Storage\Table\TableRestProxy;
    use MicrosoftAzure\Storage\Common\ServiceException;
    $connectionString = 'DefaultEndpointsProtocol=https;AccountName=xxxx;AccountKey=xxxxxxx;';
    $tableClient = TableRestProxy::createTableService($connectionString);
    try {
        $tableClient->createTable("mytable");
    }
    catch(ServiceException $e){
      $code = $e->getCode();
      $error_message = $e->getMessage();
      echo $code.": ".$error_message."<br />";
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

悬赏问题

  • ¥15 全志t113i启动qt应用程序提示internal error
  • ¥15 ensp可以看看嘛.
  • ¥80 51单片机C语言代码解决单片机为AT89C52是清翔单片机
  • ¥60 优博讯DT50高通安卓11系统刷完机自动进去fastboot模式
  • ¥15 minist数字识别
  • ¥15 在安装gym库的pygame时遇到问题,不知道如何解决
  • ¥20 uniapp中的webview 使用的是本地的vue页面,在模拟器上显示无法打开
  • ¥15 网上下载的3DMAX模型,不显示贴图怎么办
  • ¥15 关于#stm32#的问题:寻找一块开发版,作为智能化割草机的控制模块和树莓派主板相连,要求:最低可控制 3 个电机(两个驱动电机,1 个割草电机),其次可以与树莓派主板相连电机照片如下:
  • ¥15 潜在扩散模型的Unet特征提取
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部