Configuration ============= The configuration of the KeyValueStore consists of two steps. * Mapping Configuration * Storage Configuration Mapping Configuration --------------------- .. code-block:: php setMetadataCache($cache); // 3. Annotation Metadata Driver $reader = new AnnotationReader(); $metadata = new AnnotationDriver($reader); $config->setMappingDriverImpl($metadata); The mapping configuration is handled through a configuration object. 1. In the first step, a configuration object is created. 2. We need a caching mechanism for the configuration for performance. This should be different in development and production. The ``ArrayCache`` is a request-based cache, which is useful in development. Have a look at the `Doctrine Common documentation `_ for production caches. 3. Finally you have to create a metadata driver, in this example the ``AnnotationDriver`` that allows configurating mapping with Docblock annotations. Storage Configuration --------------------- Independent from the mapping configuration, which is the same for all key-value database backends, you have to configure the actual storage you want to use. This configuration is obviously specific to all the different storage drivers. So far the following drivers exist (and are documented here): * PHP Array * Doctrine Cache Backend * SQL Backend with Doctrine DBAL * Microsoft Windows Azure Table * Couchbase * CouchDB * MongoDB * Riak Also all those storage backends obviously have different dependencies in terms of PHP libraries or PHP PECL extensions. PHP Array --------- PHP array is used mainly for development and teesting purposes. .. code-block:: php `_ from Doctrine as a backend. Depending on the cache driver you get a persistent or in-memory key value store with this solution. See the `Doctrine Common documentation `_ for more details about the different supported drivers. Here is an example of configurating the Cache Storage using Redis: .. code-block:: php setRedis($conn); $storage = new DoctrineCacheStorage($cache); Doctrine DBAL Backend --------------------- You can use a relational database as backend. It uses a very simple table as storage with one primary key and a blob field that stores the properties. .. code-block:: php `_ service. You can use that as a storage layer through the Windows Azure PHP SDK: .. code-block:: php createTableService($connectionString); $storage = new AzureSdkTableStorage($client); Cassandra --------- Cassandra is supported through the `PECL extension `_ and the `DataStax PHP driver `_: .. code-block:: php build(); $session = $cluster->connect(); $session->execute(new SimpleStatement('USE doctrine')); $storage = new CassandraStorage($session); Couchbase --------- Until the version 1.2 also Couchbase is supported: .. code-block:: php `_: .. code-block:: php 'doctrine_example', )); $storage = new CouchDbStorage($client); DynamoDb --------- DynamoDb is supported through the `AWS SDK for PHP `_ Create your tables via the AWS DynamoDb console or using the `PHP based API `_ See the `AWS docs `_ for more information on configuring credentials for the client. .. code-block:: php createDynamoDb(); $storage = new DynamoDbStorage( $client, // Optional key name, defaults to Id. null, // Optional table name/ key name pairs. // This example uses a table called Awesome keyed by MyKey. ['storage_keys' => ['Awesome' => 'MyKey']] ); MongoDB ------- Mongo support is provided using a `Mongo `_ instance, the collection name and the database name. Both the options ``collection`` and ``database`` are required. .. code-block:: php 'your_collection', 'database' => 'your_database', )); Riak ---- Riak support is provided through the library `riak/riak-client `_ : .. code-block:: php