简体   繁体   中英

PHP - can't find Azure class createcontaineroptions

I am following this tutorial on using globs in Azure storage with PHP:

https://azure.microsoft.com/en-us/documentation/articles/storage-php-how-to-use-blobs/

I used composer to get all the necessary dependencies. Here is my composer.json:

{
    "repositories": [
        {
            "type": "pear",
            "url": "https://pear.php.net"
        }
    ],
    "require": {
        "pear-pear.php.net/mail_mime" : "*",
        "pear-pear.php.net/http_request2" : "*",
        "pear-pear.php.net/mail_mimedecode" : "*",
        "microsoft/windowsazure": "*"
    }
}

I do "composer update" and it appears to get everything needed.

In PHP I do:

<?php
require_once 'vendor\autoload.php';


use WindowsAzure\Common\ServicesBuilder;
use WindowsAzure\Blob\Models\CreateContainerOptions;
use WindowsAzure\Blob\Models\PublicAccessType;
use WindowsAzure\Common\ServiceException;

$createContainerOptions = new CreateContainerOptions();

And that gives an error:

Fatal error: Class 'WindowsAzure\\Blob\\Models\\CreateContainerOptions' not found in C:\\myproject\\azure.php on line 18.

I did print_r(get_declared_classes()); and sure enough, CreateContainerOptions is not in the list.

Can you please tell me what is wrong with my require or use statements that it doesn't pull in the CreateContainerOptions class?

Thank you!

As the latest version of Azure SDK for PHP, the Storage SDK has changed the repository to https://github.com/Azure/azure-storage-php . You can check the structure in vendor/microsoft folder.

And also, the namespace of CreateContainerOptions has changed to MicrosoftAzure\\Storage\\Blob\\Models\\CreateContainerOptions . Please refer to https://github.com/Azure/azure-storage-php/blob/master/src/Blob/Models/CreateContainerOptions.php#L25 .

So, to implement storage operations via latest PHP SDK, please refer to https://github.com/Azure/azure-storage-php .

Any further concern, please feel free to let me know.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM