Uncaught Error: Class 'WindowsAzure\Common\ServicesBuilder' not found- MS Azure | PHP
Uncaught Error: Class 'WindowsAzure\Common\ServicesBuilder' not found- MS Azure | PHP
我在我的 index.php 文件所在的根文件夹中创建了 composer.json 文件,其中包含以下代码:
{
"require": {
"microsoft/windowsazure": "^0.5"
}
}
在下载 composer.phar 时,我使用以下方法安装了它:
php composer.phar install
我正在尝试创建一个 table 并在 php 中向其添加实体。我使用命令
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 />";
}
当我 运行 在我 Ubuntu 的本地主机上执行此操作时,我收到一条错误消息 -
Uncaught Error: Class 'WindowsAzure\Common\ServicesBuilder' not found in /home/my_folder/php-docs-hello-world-master/index.php:30
如果我加上
require_once 'vendor/autoload.php';
在定义我的 $connectionString 之前,我的错误变为:
/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 "http" - did you forget to enable it when you configured PHP?
有人可以帮我解决这个问题吗,如果它与我的作曲家、我的 connectionString 或其他东西的安装有关?
提前致谢:)
Can someone help me figure out this issue, if it is with the installation of my composer, or my connectionString, or something else?
如果我使用你提到的代码,我也可以重现你提到的问题。
请尝试使用以下代码创建 table 客户端。它对我有用。
use MicrosoftAzure\Storage\Table\TableRestProxy;
use MicrosoftAzure\Storage\Common\ServiceException;
$tableClient = TableRestProxy::createTableService($connectionString);
以下是azure的demo代码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 />";
}
我在我的 index.php 文件所在的根文件夹中创建了 composer.json 文件,其中包含以下代码:
{
"require": {
"microsoft/windowsazure": "^0.5"
}
}
在下载 composer.phar 时,我使用以下方法安装了它:
php composer.phar install
我正在尝试创建一个 table 并在 php 中向其添加实体。我使用命令
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 />";
}
当我 运行 在我 Ubuntu 的本地主机上执行此操作时,我收到一条错误消息 -
Uncaught Error: Class 'WindowsAzure\Common\ServicesBuilder' not found in /home/my_folder/php-docs-hello-world-master/index.php:30
如果我加上
require_once 'vendor/autoload.php';
在定义我的 $connectionString 之前,我的错误变为:
/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 "http" - did you forget to enable it when you configured PHP?
有人可以帮我解决这个问题吗,如果它与我的作曲家、我的 connectionString 或其他东西的安装有关?
提前致谢:)
Can someone help me figure out this issue, if it is with the installation of my composer, or my connectionString, or something else?
如果我使用你提到的代码,我也可以重现你提到的问题。
请尝试使用以下代码创建 table 客户端。它对我有用。
use MicrosoftAzure\Storage\Table\TableRestProxy;
use MicrosoftAzure\Storage\Common\ServiceException;
$tableClient = TableRestProxy::createTableService($connectionString);
以下是azure的demo代码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 />";
}