我有以下代码在 UserFrosting 之外按预期工作:
<?php
echo "Hello World.<br>";
require_once '../vendor/autoload.php';
use Aws\Common\Aws;
$aws = Aws::factory('../aws/aws-config.json');
$client = $aws->get('S3');
$bucket = 'my-public-public';
$iterator = $client->getIterator('ListObjects', array(
'Bucket' => $bucket
));
foreach ($iterator as $object) {
echo $object['Key'] . "<br>";
}
在我的 UserFrosting 实例上,我设法使用 Composer 成功加载aws-sdk-php:
- Installing aws/aws-sdk-php (3.19.24)
Downloading: 100%
使用 Aws\Common\Aws;放在initialize.php中,下面是对 Slim 的引用:
use \Slim\Extras\Middleware\CsrfGuard;
use Aws\Common\Aws;
其余代码在控制器中:
public function readS3(){
$aws = Aws::factory('../aws/aws-config.json');
$client = $aws->get('S3');
...
}
我仍然收到以下错误:
未找到“UserFrosting\Aws”类。
我错过了什么?