PHP code example of not-empty / aws-bucket-php-lib

1. Go to this page and download the library: Download not-empty/aws-bucket-php-lib library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

not-empty / aws-bucket-php-lib example snippets


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);

$listFiles = $awsBucket->listFiles(
    $bucket
);
var_dump($listFiles);

...
$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 here
sh
php sample/aws-bucket-sample.php