PHP Classes


Recommend this page to a friend!
  Classes of Joseluis Laso  >  PHP AWS S3 SDK Wrapper  >  >  Download  
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: PHP AWS S3 SDK Wrapper
Retrieve and cache AWS S3 files using the SDK
Author: By
Last change: sanitizing code and documentation
Date: 6 years ago
Size: 1,399 bytes


Class file image Download


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

For more information send a message to info at phpclasses dot org.