softsmart / awss3
Simple AWSS3 implementation
1.0.4
2020-04-28 06:33 UTC
Requires
- php: >=5.4.0
Requires (Dev)
- phpunit/phpunit: ^6.5
This package is auto-updated.
Last update: 2025-04-28 17:14:49 UTC
README
A simple AWS S3 GET, PUT, DELETE implementation in PHP using AWS Rest interface
Install
Via Composer
$ composer require softsmart/awss3
Usage
$object = new AWSS3();
$awsAccessKeyId = "MyAwsAccessKeyId";
$awsSecretAccessKey = "My/AwsSecret/Access/Key";
$bucketName = "MyBucketName";
$region = "us-east-2";
// GET an object
$return = $object->get('/dog.png', $awsAccessKeyId, $awsSecretAccessKey, $bucketName, $region);
if ($return["httpCode"] == 200) {
file_put_contents(dirname(__FILE__)."/dog.png", $return["content"]);
print "<img src=\"dog.png\">";
}
// PUT an object
$return = $object->put(dirname(__FILE__)."/dog.png", "/dog.png", $awsAccessKeyId, $awsSecretAccessKey, $bucketName, $region);
// DELETE an object
$return = $object->delete('/dog.png', $awsAccessKeyId, $awsSecretAccessKey, $bucketName, $region);
Testing
$ phpcs -c phpunit.xml
Contributing
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
Credits
License
GNU GENERAL PUBLIC LICENSE. Please see License File for more information.
Questions
Q: Why not just use their SDK?
A: Its probably best but the SDK is for all Amazon products. It seems like overkill if all you want to do is add and delete files to an S3 bucket (eg, for remote images).