我在 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/