PHP library to connect to and use AWS S3 Bucket.
Release 8.0.0 Requires PHP 8.4
Release 7.0.0 Requires PHP 8.3
Release 6.0.0 Requires PHP 8.2
Release 5.0.0 Requires PHP 8.1
Release 4.0.0 Requires PHP 7.4
Release 3.0.0 Requires PHP 7.3
Release 2.0.0 Requires PHP 7.2
Release 1.0.0 Requires PHP 7.1
The recommended way to install is through Composer.
composer require not-empty/aws-bucket-php-libPutting a file
use AwsBucket\AwsBucket;
$config = [
'credentials' => [
'key' => '', //you must put your aws iam key here
'secret' => '', //you must put your aws iam secret here
],
'version' => 'latest',
'region' => 'us-east-1', //you must put your bucket region here
];
$awsBucket = new AwsBucket($config);
$bucket = 'my-bucket'; //you must put your bucket name here
$content = 'this is your file content';
$name = 'sample';
$extension = 'txt';
$putFile = $awsBucket->putFile(
$bucket,
$content,
$name,
$extension
);
var_dump($putFile);Listing files
$listFiles = $awsBucket->listFiles(
$bucket
);
var_dump($listFiles);If you getting 403 or 400 erros, you must configure your bucket permitions, in AWS console to allow the files uploads.
if you want an environment to run or test it, you can build and install dependences like this
docker build --build-arg PHP_VERSION=8.4-cli -t not-empty/aws-bucket-php-lib:php84 -f contrib/Dockerfile .Access the container
docker run --name aws-bucket-php-lib -v ${PWD}/:/var/www/html -it not-empty/aws-bucket-php-lib:php84 bashVerify if all dependencies is installed
composer install --no-dev --prefer-distput your credentials, region and name of bucket in sample file sample/aws-bucket-sample.php
...
$config = [
'credentials' => [
'key' => '', //you must put your aws iam key here
'secret' => '', //you must put your aws iam secret here
],
'version' => 'latest',
'region' => 'us-east-1', //you must put your bucket region here
];
$bucket = 'my-bucket'; //you must put your bucket name hereand run
php sample/aws-bucket-sample.phpWant to contribute? Great!
The project using a simple code. Make a change in your file and be careful with your updates! Any new code will only be accepted with all validations.
To ensure that the entire project is fine:
First you need to building a correct environment to install all dependences
docker build --build-arg PHP_VERSION=8.4-cli -t not-empty/aws-bucket-php-lib:php84 -f contrib/Dockerfile .Access the container
docker run --name aws-bucket-php-lib -v ${PWD}/:/var/www/html -it not-empty/aws-bucket-php-lib:php84 bashInstall all dependences
composer install --dev --prefer-distRun all validations
composer checkNot Empty Foundation - Free codes, full minds