Recommend this page to a friend! |
![]() |
Info | Example | ![]() |
![]() |
![]() |
Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
Not yet rated by the users | Total: 238 | All time: 8,055 This week: 56![]() |
Version | License | PHP version | Categories | |||
abstractstorage 1.000.000 | GNU General Publi... | 5 | PHP 5, Files and Folders, Web services |
Description | Author | |
This package can store and retrieve data in multiple cloud services. Innovation Award
|
|
<?php
|
Storing and retrieving files with PHP is easy... right?
Yes, it is, until you find out that you were storing files in your local server and now needs to change that to Amazon S3, Google or whatever.
You hard-coded a lot of stuff in your code, and when you start to "rewire" stuff, everything starts to break. It hurts.
The objective of this repo is to create an interface for file storage. This allow us to separate the implementation for each storage provider and the actual code which just want to store/retrieve/delete a file.
The basic implementation for local storage and Amazon S3 are included.
Feel free to contribute, criticize, extend and use.
Some storage providers use different terminology for stuff. It can lead to confusion, and there's no way around it except choosing what seems the "best fit" for everything.
We use the term bucket
on the interface as a way to represent a logic place where
files are stored. In Amazon S3, that is a native term. In local storage, bucket
just means directory/folder
.
The interface itself does not have any dependencies. However the Amazon S3 implementation does. I suggest to use Composer and get the "aws/aws-sdk-php" package. Everything should be there.
//OBJECT CREATION/INITIALIZATION -- SHOULD BE IN YOUR DEPENDENCY INJECTOR CONTAINER
$storageObj = new LocalStorage();
$storageObj::setBaseStorageLocation('../storage');
//ARCHIVE A FILE
try {
$fileUID = $storage->putFile('myfile.txt', 'mybucket');
} catch (Exception $e) {
die($e->getMessage());
}
//DOWNLOAD A FILE
try {
$storage->getFile($fileUID, 'output_name.txt', 'mybucket');
} catch (Exception $e) {
die($e->getMessage());
}
![]() |
File | Role | Description | ||
---|---|---|---|---|
![]() |
||||
![]() |
||||
![]() ![]() |
Example | Example script | ||
![]() ![]() |
Lic. | License text | ||
![]() ![]() |
Doc. | Documentation |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
![]() |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.