I have the following code working as expected outside 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>";
}
On my UserFrosting instance I managed to successfully load aws-sdk-php with Composer:
- Installing aws/aws-sdk-php (3.19.24)
Downloading: 100%
use Aws\Common\Aws; is placed in initialize.php, below reference to Slim:
use \Slim\Extras\Middleware\CsrfGuard;
use Aws\Common\Aws;
The rest of the code is in the controller:
public function readS3(){
$aws = Aws::factory('../aws/aws-config.json');
$client = $aws->get('S3');
...
}
I am still getting the following error:
Class 'UserFrosting\Aws' not found.
What am I missing?