php - 如何让(新的)Azure PHP SDK 工作?

标签 php azure composer-php azure-table-storage

我在 Azure 网站上使用了旧的 PHP azure SDK,但我想迁移到新的。不幸的是,我无法让新的工作。

我已手动安装 SDK 并按照此页面上的“使用”步骤进行操作:https://github.com/Azure/azure-sdk-for-php 。我使用“require”而不是“use”,也许这就是出错的地方,但我不知道如何使用 namespace 。

我用来编辑代码的环境是 Dreamweaver。

下面的代码在以$tableRestProxy开头的行出错

<?php
    require("WindowsAzure/WindowsAzure.php"); 
    require("WindowsAzure/Common/ServicesBuilder.php");
    require("WindowsAzure/Common/ServiceException.php");
    require("WindowsAzure/Table/TableRestProxy.php");       

    $connectionString = 'DefaultEndpointsProtocol=https;AccountName=[AccountName];AccountKey=[AccountKey]';
    // I do know that I have to declare the AccountName and AccountKey here. Left it out for privacy reasons.       

    $tableRestProxy = ServicesBuilder::getInstance()->createTableService($connectionString);
?>
<小时/>

更新

现在我尝试使用 Composer 来安装 SDK。我的composer.json 文件如下所示:

{
    "require": {
        "microsoft/windowsazure": "*"
    },          
    "repositories": [
        {
            "type": "pear",
            "url": "http://pear.php.net"
        }
    ],
    "minimum-stability": "dev"
}

当我运行composer.phar时,我得到以下结果:

Onwijs@JEROENVINK /e/Users/Public/Documents/00_speeltuin_azure/newsdk
$ php composer.phar diagnose
Checking composer.json: OK
Checking platform settings: FAIL

The xdebug extension is loaded, this can slow down Composer a little.
Disabling it when using Composer is recommended, but should not cause issues bey
ond slowness.
Checking git settings: OK
Checking http connectivity: OK
Checking disk free space: OK
Checking composer version: OK

Onwijs@JEROENVINK /e/Users/Public/Documents/00_speeltuin_azure/newsdk
$ php composer.phar install
Loading composer repositories with package information
Initializing PEAR repository http://pear.php.net
Installing dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for microsoft/windowsazure 0.4.0 -> satisfiable by mi
crosoft/windowsazure[v0.4.0].
    - microsoft/windowsazure v0.4.0 requires pear-pear/http_request2 * -> no mat
ching package found.

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your min
imum-stability setting
   see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> f
or more details.

Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common
 problems.

我不明白我做错了什么。

最佳答案

pear 和通过 Composer 提供的 Azure SDK 似乎存在问题。

我找到了解决这个问题的方法,将我的composer.json 文件修改为如下所示:

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

注意三行:

"pear-pear.php.net/http_request2": "*",
"pear-pear.php.net/mail_mime": "*",
"pear-pear.php.net/mail_mimedecode": "*"

这些为 Composer 提供了更明确的信息,并且使用这种方法似乎组合得很好。

希望有帮助。

关于php - 如何让(新的)Azure PHP SDK 工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24407598/

相关文章:

azure - MVC Web 角色构建后事件

azure - 一封电子邮件中包含多个 HTML 表格,包含标题和表格

php - 如何告诉命名空间下的类列表

php - 我应该用 GIT 发送我的 Composer 供应商目录吗

php - Composer 返回 proc_open(NUL) 无法打开流,没有这样的目录

javascript - Ajax请求文档准备好会导致jquery加载缓慢

php - 并行执行函数

sql - 为什么 Azure SQL 数据库如此昂贵?

php - 是否可以在 laravel 中使用 "hasMany"关联同一张表?

php - *nix : Performing nested -exec with find command