KnpGaufretteBundle
KnpGaufretteBundle copied to clipboard
Add README and instructions about AmazonS3 usage
Hi, I'm trying to use Amazon S3 as filesystem using KnpGaufretteBundle but I don't understand how to do it and readme doesn't show anything about S3. Could anyone explain me what should I do? :(
Thanks!
Hello, thanks for information. Will try to update README with some examples, right now open issue to remember about that.
+1
I think there is an issue with composer. I have this configuration:
"require": {
...
"knplabs/knp-gaufrette-bundle": "dev-master"
},
but it looks like the vendor amazonwebservices/aws-sdk-for-php
or aws/aws-sdk-php
(not sure which version is used here) is not downloading ending up not finding the required AmazonS3 class to setup the service.
Here is my gaufrette configuration:
# app/config/config.yml
knp_gaufrette:
adapters:
amazon:
amazon_s3:
amazon_s3_id: service.amazon.s3
bucket_name: %amazon.bucket%
create: true
filesystems:
amazon:
adapter: amazon
stream_wrapper:
protocol: data
# Acme/DemoBundle/Resources/config/service.yml
services:
service.amazon.s3:
class: AmazonS3 # I've tried "Amazon" too
arguments: [%amazon.key%, %amazon.secret%, %amazon.token%]
# app/config/paramters.yml
parameters:
amazon.key: "s3 application key"
amazon.secret: "s3 secret key"
amazon.token: "never used a token before, I guess it's from oAuth"
amazon.bucket: "the bucket you want to use"
And with this setup I get:
" Class 'AmazonS3' not found" or " Class 'Amazon' not found"
UPDATE:
So it was what I was thinking Gaufrette
is not downloading the amazon module automatically, you need to add it in your composer.json (would it be possible to add it in the composer.json of Gaufrette
directly?):
"require": {
...
"knplabs/knp-gaufrette-bundle": "dev-master",
"amazonwebservices/aws-sdk-for-php" : "*"
},
After updating composer (php composer.phar update
) everything is working.
To save a file on Amazon (into a controller) just use the following code:
// Get the defined filesystem
$filesystem = $this->get('knp_gaufrette.filesystem_map')->get('amazon');
// write the file
$filesystem->write('maxime/test.txt' , 'my test', true);
We do not want add amazonwebservices/aws-sdk-for-php
directly cause it is optional dependency. We have it in suggest composer block so it should be printed when you run composer install IIRC https://github.com/KnpLabs/Gaufrette/blob/master/composer.json#L55
We should add this in the documentation section to setup AWS S3 filesystem.
Actually we should move the documentation in the Resources/doc
and organise it by file.
One file per filesystem, configuration + exemple would be great.
What do you think ?
:+1: for more documentation an especially the S3 setup. Thanks for this Bundle!
+1 for S3 setup
+1 for S3 setup
+1 for S3 setup. It's pretty confusing right now. Especially with the required CA but no information about that.
Well, this issue is almost three years old. So, how do you feel guys, is the docs in https://github.com/KnpLabs/KnpGaufretteBundle#amazon-s3-amazon_s3 enough for the moment? Should we update it? What are you missing in the current doc? Thanks in advance.
:+1:
I close this issue. As mentioned by @akovalyov, a documentation is available. Please feel free to reopen it if necessary.