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).
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.
You are looking for the library called Gaufrette. There is also KnpGaufretteBundle available for Symfony2. It has all you need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With