Giter Site home page Giter Site logo

aws-sdk-php-symfony's Introduction

AWS Service Provider for Symfony 6/7

Total Downloads

A Symfony bundle for including the AWS SDK for PHP.


Install

composer require tomasvotruba/aws-sdk-php-symfony

and add Aws\Symfony\AwsBundle to the Kernel:

class AppKernel extends Kernel
{
    public function registerBundles(): array
    {
        return [
            ...
            new \Aws\Symfony\AwsBundle(),
        ];
    }
    ...
}

Configuration

By default, configuration is handled by the SDK rather than by the bundle, and no validation is performed at compile time. Full documentation of the configuration options available can be read in the SDK Guide.

If AWS_MERGE_CONFIG environment variable is set to true, configuration validation and merging are enabled. The bundle validates and merges known configuration options, including for each service. Additional configuration options can be included in a single configuration file, but merging will fail if non-standard options are specified in more than once.

To use a service for any configuration value, use @ followed by the service name, such as @a_service. This syntax will be converted to a service during container compilation. If you want to use a string literal that begins with @, you will need to escape it by adding another @ sign.

When using the SDK from an EC2 instance, you can write credentials: ~ to use instance profile credentials. This syntax means that temporary credentials will be automatically retrieved from the EC2 instance's metadata server. It's also the preferred technique for providing credentials to applications running on that specific context.

Sample configuration can be found in the tests/fixtures folder for YAML, PHP, and XML.


Sample YML Configuration

The sample configuration which can be placed in app/config/config.yml file.

framework:
    secret: "Rosebud was the name of his sled."

aws:
    version: latest
    region: us-east-1
    credentials:
        key: not-a-real-key
        secret: "@@not-a-real-secret" # this will be escaped as '@not-a-real-secret'
    DynamoDb:
        region: us-west-2
    S3:
        version: '2006-03-01'
    Sqs:
        credentials: "@a_service"
    CloudSearchDomain:
        endpoint: https://search-with-some-subdomain.us-east-1.cloudsearch.amazonaws.com

services:
    a_service:
        class: Aws\Credentials\Credentials
        arguments:
            - a-different-fake-key
            - a-different-fake-secret

Usage

This bundle exposes an instance of the Aws\Sdk object as well as instances of each AWS client object as services to your symfony application. They are name aws.{$namespace}, where $namespace is the namespace of the service client. For instance:

Service Instance Of
aws.dynamodb Aws\DynamoDb\DynamoDbClient
aws.ec2 Aws\Ec2\Ec2Client
aws.s3 Aws\S3\S3Client
aws_sdk Aws\Sdk

The services made available depends on which version of the SDK is installed. To view a full list, run the following command from your application's root directory:

php bin/console debug:container aws

Full documentation on each of the services listed can be found in the SDK API docs.

aws-sdk-php-symfony's People

Contributors

jeskew avatar howardlopez avatar stobrien89 avatar tomasvotruba avatar samremis avatar kstich avatar diehlaws avatar vincentlanglet avatar clementtalleu avatar greg0ire avatar joksnet avatar kerihenare avatar bits4breakfast avatar mpdude avatar spajxo avatar piotrpasich avatar somayab avatar sylvaindeloux avatar develth avatar trandangtri avatar cjyclaire avatar kellertk avatar pzorn avatar extreme avatar hyandell avatar orkin avatar khez avatar chrisguitarguy avatar brianfreytag avatar aws-sdk-php-automation avatar

Stargazers

Remco Raaijmakers avatar  avatar Thanh Trần avatar Manuel Dalla Lana avatar Blaze avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.