PHP Classes

PHP AWS S3 SDK Wrapper: Retrieve and cache AWS S3 files using the SDK

Recommend this page to a friend!
  Info   Demos   View files View files (6)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 174 All time: 8,784 This week: 206Up
Version License PHP version Categories
aws-s3-wrapper 1.0.1MIT/X Consortium ...5.4PHP 5, Files and Folders, Cache, Web ...


This class can retrieve and cache AWS S3 files using the SDK.

It is a wrapper around Amazon Web Services S3 Storage to store and retrieve files.

The retrieved files can be cache in local files to avoid retrieving again files that were not modified since the cached files were retrieved.

The class can also list the file buckets in a given account and delete file buckets as well with the locally cached copies.

Picture of Joseluis Laso
  Performance   Level  
Name: Joseluis Laso <contact>
Classes: 16 packages by
Country: Spain Spain
Age: 56
All time rank: 92519 in Spain Spain
Week rank: 280 Up11 in Spain Spain Up
Innovation award
Innovation award
Nominee: 6x

Winner: 2x



This wrapper allows minimizing S3 access, maintaining a local cache (on server).


add to the composer.json file of your project {

"require": {
   "jlaso/aws-s3-wrapper": "dev-master",


and run `composer update`

or run


You can use the src/config.ini  (created from src/config.ini.sample)  in order to simplify access to the wrapper with

Or you can create your own instance passing the data the wrapper needs to be created:
new S3Wrapper($accessKey, $secretKey, $bucket);

You have to create cache folder and give 0755 permissions. Likely you have to change the owner/group to apache user/group.

In order to OOB test you can use the file samples/basic.php.


###Fetch the content o a file.

$s3 = new S3Wrapper($access, $secretm $bucket); $s3->getFileIfNewest($localFile, $remoteFile); // you have now the contents of $remoteFile on $localFile

###Save a file.

$s3 = new S3Wrapper($access, $secretm $bucket); $s3->saveFile($remoteFile, $content);

###Get the list of files.

$s3 = new S3Wrapper($access, $secretm $bucket); $fileList = $s3->getFilesList($path);

###Delete a file

$s3 = new S3Wrapper($access, $secretm $bucket); $s3->deleteFile($localFile, $remoteFile);

  Online demoExternal page  

Open in a separate window

  Files folder image Files  
File Role Description
Files folder imagesamples (1 file)
Files folder imagesrc (2 files)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file Doc. Documentation

  Files folder image Files  /  samples  
File Role Description
  Accessible without login Plain text file basic.php Example Example script

  Files folder image Files  /  src  
File Role Description
  Accessible without login Plain text file config.ini.sample Data Auxiliary data
  Accessible without login Plain text file S3Wrapper.php Class Class source

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:8,784
This week:206Up