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).
You are looking for the library called Gaufrette. There is also KnpGaufretteBundle available for Symfony2. It has all you need.