KnpGaufette/Symfony2的/ AmazonS3

And*_*erj 4 php configuration curl amazon-s3 symfony

我正在尝试将Symfony2,KnpGaufetteBundle和Amazon S3结合起来.从KnpGaufette Bundle我得到一个xml定义用于我的配置.但它是在xml中,我的配置是在yml中.不知怎的,我无法理解它.如何在yml中定义以下变量?他们是什么意思?

<service id="acme.s3" class="AmazonS3">
    <argument type="collection">
        <argument key="key">%acme.aws_key%</argument>
        <argument key="secret">%acme.aws_secret_key%</argument>
    </argument>
</service>

<service id="acme.s3.adapter" class="Gaufrette\Adapter\AmazonS3">
    <argument type="service" id="acme.s3"></argument>
    <argument>%acme.s3.bucket_name%</argument>
</service>

<service id="acme.fs" class="Gaufrette\Filesystem">
    <argument type="service" id="acme.s3.adapter"></argument>
</service>
Run Code Online (Sandbox Code Playgroud)

使用完整解决方案更新

所以,要实际让它工作,不仅我们必须在yml中放下配置(已经由chmeliuk解决 - >谢谢),但我们还需要为curl配置cacert.pem文件.你可以在这里找到一个合适的:http://curl.haxx.se/ca/cacert.pem

现在把它放在你想要的任何地方,然后使用以下行和附加的certificate_authority条目:

services:
    acme.s3:
        class: AmazonS3
        arguments:
            options: { key: %acme.aws_key%, secret: %acme.aws_secret_key%, certificate_authority: "pathWhereYouDidPutThisFile/cacert.pem" }

    acme.s3.adapter:
        class: Gaufrette\Adapter\AmazonS3
        arguments: 
            service: @acme.s3
            bucket_name: %acme.s3.bucket_name%

    acme.fs:
        class: Gaufrette\Filesystem
        arguments: 
            adapter: @acme.s3.adapter
Run Code Online (Sandbox Code Playgroud)

这解决了CA Cert cURL Error 60,否则您可能会遇到此问题.

chm*_*iuk 5

相同的配置,但采用yml格式.

services:
    acme.s3:
        class: AmazonS3
        arguments:
            options: { key: %acme.aws_key%, secret: %acme.aws_secret_key% }

    acme.s3.adapter:
        class: Gaufrette\Adapter\AmazonS3
        arguments: 
            service: @acme.s3
            bucket_name: %acme.s3.bucket_name%

    acme.fs:
        class: Gaufrette\Filesystem
        arguments: 
            adapter: @acme.s3.adapter
Run Code Online (Sandbox Code Playgroud)

定义以下参数:%acme.aws_key%,%acme.aws_secret_key%,%acme.s3.bucket_name%添加到项目parameters.yml文件(或定义服务的同一配置)下一行:

parameters:
    acme.aws_key: YOUR_AWS_KEY
    acme.aws_secret_key: YOUR_AWS_SECRET_KEY
    acme.s3.bucket_name: cool_bucket_name
Run Code Online (Sandbox Code Playgroud)