首页 > 解决方案 > 适用于 PHP 的 Microsoft Azure SDK 出现错误:未定义类型“MicrosoftAzure\Storage\Blob\BlobRestProxy”

问题描述

我已经安装了 PHP8,并从https://github.com/Azure/azure-storage-php.git克隆了 Microsoftazure SDK 。 如微软文档中所述,我还克隆了https://github.com/Azure-Samples/storage-blobs-php-quickstart.git 。我的文件结构是

-try
--azure-storage-php
--storage-blobs-php-quickstart
--vendor
--composer.json
--composer.lock
--composer.phar

在示例应用程序中,有一个文件名为“phpQS.php”。在这个文件中,我有一个代码

require_once '../vendor/autoload.php';
require_once "./random_string.php";

use MicrosoftAzure\Storage\Blob\BlobRestProxy;
use MicrosoftAzure\Storage\Common\Exceptions\ServiceException;
use MicrosoftAzure\Storage\Blob\Models\ListBlobsOptions;
// use MicrosoftAzure\Storage\Blob\Models\CreateContainerOptions;
use MicrosoftAzure\Storage\Blob\Models\CreateContainerOptions;
use MicrosoftAzure\Storage\Blob\Models\PublicAccessType;

$connectionString = "DefaultEndpointsProtocol=https;AccountName=".getenv('ACCOUNT_NAME').";AccountKey=".getenv('ACCOUNT_KEY');

// Create blob client.
$blobClient = BlobRestProxy::createBlobService($connectionString);

$fileToUpload = "HelloWorld.txt";

if (!isset($_GET["Cleanup"])) {
    // Create container options object.
    $createContainerOptions = new CreateContainerOptions();

我有错误Undefined type 'MicrosoftAzure\Storage\Blob\BlobRestProxy'Undefined type 'MicrosoftAzure\Storage\Blob\Models\CreateContainerOptions'. 我该如何解决这个问题?文件结构或文件本身是否有问题?

标签: phpazure

解决方案


推荐阅读