我想知道如何在Symfony2中包装aws php sdk(aws/aws-sdk-php),以便与SonataMediaBundle一起用作cdn。
我现在的奏鸣曲:
sonata_media:
default_context: default
db_driver: doctrine_orm
contexts:
default:
providers:
- sonata.media.provider.image
formats:
default: { width: 100 , height: 100, quality: 70}
avatar:
providers:
- sonata.media.provider.image
formats:
medium: { width: 750 , quality: 90}
cdn:
server:
path: http://%s3_bucket_name%.s3-website-%s3_region%.amazonaws.com/%env%
providers:
image:
filesystem: sonata.media.filesystem.s3
service: sonata.media.provider.image
filesystem:
local:
directory: %kernel.root_dir%/../web/uploads/media
create: false
s3:
bucket: %s3_bucket_name%
accessKey: %s3_access_key%
secretKey: %s3_secret_key%
region: %s3_region%@
directory: %env%
但我收到错误:Attempted to load class "AmazonS3" from the global namespace
。
答案 0 :(得分:2)
显然,使用配置文件是正确的做法,在这种情况下,我们以这种方式修复了我们的问题:
cdn:
server:
#path: http://%s3_bucket_name%.s3-website-%s3_region%.amazonaws.com/%env%
path: http://%s3_region%/%s3_bucket_name%/selfies/%env% # this one is working
使用以下s3_region值:s3_region: s3-eu-west-1.amazonaws.com
答案 1 :(得分:1)
如果您使用sonata-project/media-bundle
< = 2.3.3,请尝试使用https://packagist.org/packages/amazonwebservices/aws-sdk-for-php。
正如你在packagist所看到的那样
https://packagist.org/packages/sonata-project/media-bundle
或者在最新版本的composer.json
https://github.com/sonata-project/SonataMediaBundle/blob/2.3.3/composer.json#L37,它需要/建议旧的amazonwebservices/aws-sdk-for-php: ~1.5
,而不是新的aws/aws-sdk-php
。
只有aws/aws-sdk-php
https://packagist.org/packages/sonata-project/media-bundle版本才需要新的dev-master
。