带有 AWS 客户端的 Symfony 3 抛出 AnnotationException(“@http”注释)

Symfony 3 with AWS Client throws AnnotationException ("@http" annotation)

我即将在我的 Symfony 3.0 项目中使用 KnpGaufretteBundle,它使用 aws/aws-php-sdk 依赖项。

我已经配置了我的服务,将 AWS 凭证和客户端定义为服务。

<!-- AWS -->
    <service id="app.aws_credentials" class="Aws\Credentials\Credentials">
        <argument>%aws_access_key_id%</argument>
        <argument>%aws_secret_access_key%</argument>
    </service>
    <service id="app.aws_s3.client" class="Aws\S3\S3Client">
        <argument type="collection">
            <argument key="region">%aws_s3_region%</argument>
            <argument key="version">%aws_sdk_version%</argument>
            <argument key="credentials" type="service" id="app.aws_credentials"/>
        </argument>
    </service>

当我 运行 composer updatecache:clear 失败并抛出以下内容时,糟糕的部分开始:

    [Doctrine\Common\Annotations\AnnotationException]                                                                                                                                
         [Semantical Error] The annotation "@http" in method Aws\AwsClientInterface::getCommand() was never imported. Did you maybe forget to add a "use" statement for this annotation? 

@http 似乎不是做任何事情的注解。

有什么解决办法吗?

很久以前就想出来了,只是忘了在这里说。

Symfony Bundle,由 Amazon 帮助提供,可在 https://github.com/aws/aws-sdk-php-symfony

获得

我只是使用了 aws/aws-sdk-php-symfony composer 包提供的服务,而不是自己定义它们。

很有魅力:)