2017 © Pedro Peláez
 

symfony-bundle dynamodb-connector-bundle

Symfony 2 DynamoDB connexion service designed to work with cpliakas/dynamo-db-odm

image

zeliard91/dynamodb-connector-bundle

Symfony 2 DynamoDB connexion service designed to work with cpliakas/dynamo-db-odm

  • Saturday, September 6, 2014
  • by zeliard91
  • Repository
  • 2 Watchers
  • 1 Stars
  • 34 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Zeliard91DynamoDBConnectorBundle

This bundle provides a symfony 2 service to interact with cpliakas/dynamo-db-odm., (*1)

Installation

Installation is a quick 3 step process:, (*2)

  1. Download Zeliard91DynamoDBConnectorBundle using composer
  2. Enable the Bundle
  3. Configure your application's config.yml

Step 1: Download Zeliard91DynamoDBConnectorBundle using composer

Add Zeliard91DynamoDBConnectorBundle in your composer.json:, (*3)

{
    "require": {
        "zeliard91/dynamodb-connector-bundle": "dev-master"
    }
}

Now tell composer to download the bundle by running the command:, (*4)

``` bash $ php composer.phar update zeliard91/dynamodb-connector-bundle, (*5)


Composer will install the bundle to your project's `vendor/zeliard91/dynamodb-connector-bundle` directory. ### Step 2: Enable the bundle Enable the bundle in the kernel: ``` php <?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Zeliard91\Bundle\DynamoDBConnectorBundle\Zeliard91DynamoDBConnectorBundle(), ); }

Step3: Add your DynamoDB credentials in your project configuration file

``` yaml, (*6)

app/config/config.yml

zeliard91_dynamo_db_connector: # get the values from parameters.yml key: "%dynamodb_key%" secret: "%dynamodb_secret%" region: "eu-west-1" # optional : for dev, you can specify base url base_url: "%dynamodb_url%" # optional : location of your entities entity_namespaces: - Foo\BarBundle\Entity, (*7)


## Usage ### Access to service objects You can get DynamoDB client and document manager in your application by calling the service. ``` php <?php $document_manager = $this->get('zeliard91_dynamo_db_connector')->getManager(); $dynamo_client = $this->get('zeliard91_dynamo_db_connector')->getDynamoDb(); $schema_manager = $this->get('zeliard91_dynamo_db_connector')->getSchemaManager();

Entity repositories

If you have register entity namespace, you can also create repositories classes in order to define queries., (*8)

Let's assume you have created the entity Foo\BarBundle\Entity\Book.php, (*9)

Now define the repository class, it has to be in the same directory and must end by 'Repository' :, (*10)

``` php <?php // Foo/BarBundle/Entity/BookRepository.php, (*11)

namespace Foo\BarBundle\Entity;, (*12)

use Zeliard91\Bundle\DynamoDBConnectorBundle\Repository\DefaultRepository as Repository; use Cpliakas\DynamoDb\ODM\Conditions; use Aws\DynamoDb\Enum\ComparisonOperator;, (*13)

class BookRepository extends Repository { /** * Find all books from an author * @param string $author * @return array */ public function findByAuthor($author) { $conditions = Conditions::factory() ->addCondition('author', $author, ComparisonOperator::EQ) ; return $this->scan($conditions); } }, (*14)


You can now call the method in your controller : ``` php <?php $book_repository = $this->get('zeliard91_dynamo_db_connector')->getRepository('Book'); $books = $book_repository->findByAuthor($author); // Here are some methods from the extended DefaultRepository $book = $book_repository->find($id); $book = $book_repository->find($id, $range); // if you have defined a range attribute $books = $book_repository->findAll();

Schema Manager

By using this object, you can create, check or delete the table linked to your entity, (*15)

``` php <?php, (*16)

$schema_manager = $this->get('zeliard91_dynamo_db_connector')->getSchemaManager();, (*17)

$schema_manager->isTableExists('Book'); // returns true or false $schema_manager->createTable('Book'); // throws exception if table already exists $schema_manager->deleteTable('Book'); // throws exception if table does not exist, (*18)

```, (*19)

The Versions

06/09 2014

dev-master

9999999-dev https://github.com/zeliard91/DynamoDBConnectorBundle

Symfony 2 DynamoDB connexion service designed to work with cpliakas/dynamo-db-odm

  Sources   Download

MIT

The Requires

 

sf2 connector dynamodb zeliard91