2013-06-05 155 views
2

我想让我的Symfony2项目中运行LiipImagine,使用KnpGraufette Bundle来访问我的亚马逊AWS S3帐户。Symfony2与KnpGaufrette与S3与LiipImagine

现在我已经可以访问S3,存储和加载数据和所有。 我可以使用LiipImagine来过滤本地图像。 目前为止这么好。

现在我使用下面的配置将我的gaufrette/s3服务和本教程中显示的LiipImagine ans粘合在一起。

services: 
    amazonS3: 
    class: AmazonS3 
    arguments: 
     options: 
     key: '%aws_key%' 
     secret: '%aws_secret_key%' 
     certificate_authority: '%kernel.root_dir%/config/cacert.pem' 
    gaufrette.amazonS3_adapter: 
    class: Gaufrette\Adapter\AmazonS3 
    arguments: 
     service: '@amazonS3' 
     bucket_name: '%aws_bucketname%' 
    gaufrette.amazonS3.fileSystemService: 
    class: Gaufrette\Filesystem 
    arguments: 
     adapter: '@gaufrette.amazonS3_adapter' 
    our.fs.dataloader.s3: 
    class: Liip\ImagineBundle\Imagine\Data\Loader\FileSystemLoader 
    arguments: 
     - "@liip_imagine" 
     - "@gaufrette.amazonS3.fileSystemService" 
    tags: 
     - { name: 'liip_imagine.data.loader', loader: 'gaufrette.amazonS3.fileSystemService' } 

liip_imagine: 
    filter_sets: 
    s3_clientsbar: 
     data_loader: 'our.fs.dataloader.s3' 
     filters: 
     thumbnail: { size: [50, 50], mode: outbound, allow_upscale: true } 

当使用LiipImagine来筛选S3林资源,我得到以下错误:

ErrorException: Catchable Fatal Error: Argument 2 passed to Liip\ImagineBundle\Imagine\Data\Loader\FileSystemLoader::__construct() must be an array, object given, called in 

测试我的过滤代码是这样的:

$imagemanagerResponse = $this->container->get('liip_imagine.controller')->filterAction($this->getRequest(),'the-actual-existing-loadable-aws-id' , 's3_clientsbar'); 

再说:可能有的主持人添加标签Gaufrette,KnpGaufrette或KnpGaufretteBundle?

+0

您是否曾经解决过这个问题?你怎么做的? – turibe

+0

不,我无法访问此项目: -/ –

回答

3

我认为你不必定义自己的gaufrette亚马逊s3 adaper服务...只使用gaufette包配置。

只需使用等给出https://github.com/liip/LiipImagineBundle/blob/master/Resources/doc/data-loader/stream.md

gaufrette + LIIP配置LIIP配置则应该像这样:

services: 
    amazonS3: 
     class: AmazonS3 
     arguments: 
      options: 
       key: '%aws_key%' 
       secret: '%aws_secret_key%' 
       certificate_authority: '%kernel.root_dir%/config/cacert.pem' 

    liip_imagine.data.loader.stream.profile_photos: 
     class: "%liip_imagine.data.loader.stream.class%" 
     arguments: 
      - "@liip_imagine" 
      - 'gaufrette://amazon_fs/' 
     tags: 
      - { name: 'liip_imagine.data.loader', loader: 'stream.profile_photos' } 

knp_gaufrette: 
    stream_wrapper: ~ 
    adapters: 
     local_adapter:   
      local: 
       directory: %kernel.root_dir%/../web/uploads 
     amazon_s3_adapter: 
      amazon_s3_id: amazonS3 
      bucket_name: mybucketname 
      options: 
       create: true 

    filesystems:    
     local_fs: 
      adapter: local_adapter 
     amazon_fs: 
      adapter: amazon_s3_adapter 

只需注意例如在上面我注册了两个适配器本地和Amazon S3的。

+2

'%liip_imagine.data.loader.stream.class%'现在是'%liip_imagine.binary.loader.stream.class%' – GabrielCol