Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Library for Amazon S3 with local fallback

Is there a library out there for PHP to access Amazon S3 that will let me use the exact same code to either read/write S3 buckets or to do the same with local files?

I would like to use S3 but I need a way to run my application locally for testing.

If there is not a library that directly supports switching to a local filesystem, is there one that is written in a good OOP manner so that I could use the same interface to make a local filesystem version of it?

I'm using Symfony2 so if there are bundles for this that would be a plus but I can always make it a bundle myself.

UPDATE

I'm trying to make a bundle now to do this. I just need the operations "create", "exists", and "delete" so I made an interface to handle that. Then I have a "local" implementation and an "S3" implementation.

What's a clean, Symfony2 method of allowing another class to access some service by ID and get either the LocalStorage or the S3Storage class depending on a config parameter? I thought about using a "class" parameter, but my S3 service has a dependency on the underlying AmazonS3 class (using the AWS bundle).

like image 941
Matt Avatar asked Feb 27 '12 02:02

Matt


People also ask

Can I run PHP on S3?

S3 doesn't run any sort of CGI script (PHP, Perl, Ruby, etc). Think of it as a static html and image repository. If you want to host your PHP application on AWS, consider using AWS Beanstalk. It will launch an environment (server, IP, etc) where you can deploy and run your PHP application easily.


1 Answers

You are looking for the library called Gaufrette. There is also KnpGaufretteBundle available for Symfony2. It has all you need.

like image 140
Anton Babenko Avatar answered Oct 07 '22 01:10

Anton Babenko