2017 © Pedro Peláez
 

library broadway-mongodb

A mongodb driver for Broadway

image

madewithlove/broadway-mongodb

A mongodb driver for Broadway

  • Friday, April 22, 2016
  • by bramdevries
  • Repository
  • 2 Watchers
  • 1 Stars
  • 42 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

madewithlove/broadway-mongodb

Build Status Latest Stable Version Total Downloads Scrutinizer Quality Score Code Coverage, (*1)

A MongoDB driver for Broadway based on mongodb/mongodb., (*2)

Goals

Install

This package has the same requirements as mongodb/mongodb., (*3)

$ pecl install mongodb
$ echo "extension=mongodb.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`

Via Composer, (*4)

``` bash $ composer require madewithlove/broadway-mongodb, (*5)


## Usage ### `MongoDBClientFactory` This package ships with a factory to build a `MongoDB\Client`. #### Using default values ```php $factory = new MongoDBClientFactory(); $client = $factory->create(['database' => 'foobar']);

Creating a client for a specific host and port

$factory = new MongoDBClientFactory();
$client = $factory->create([
     'database' => 'foobar',
     'host' => 'my_host',
     'port' => 3000,
]);

// Or alternatively

$client = $factory->create([
     'database' => 'foobar',
     'host' => 'my_host:3000',
]);

Creating a client for multiple hosts

The hosts option can also be an array for multiple hosts, (*6)

$factory = new MongoDBClientFactory();
$client = $factory->create([
     'database' => 'foobar',
     'host' => ['my_host_1', 'my_host_2'],
]);

Creating a client for with username and password

If you have to authenticate to your MongoDB database you can pass the username and password, (*7)

$factory = new MongoDBClientFactory();
$client = $factory->create([
     'database' => 'foobar',
     'username' => 'foo',
     'password' => 'bar',
]);

Creating a client using a dsn string

Alternatively you can pass a dsn string and it will be used to connect, (*8)

$factory = new MongoDBClientFactory();
$client = $factory->create([
     'dsn' => 'mongodb://foo:200/foo',
]);

ReadModel

This package ships with a basic MongoDBRepository class you can either use directly or extend to build your own repositories., (*9)

The easiest way to create a repository for your model is by using the ReadModel\Factory:, (*10)

```php, (*11)

$mongDBClientFactory = new MongoDBClientFactory(); $client = $factory->create(['database' => 'testing']);, (*12)

$factory = new ReadModel\Factory( new SimpleInterfaceSerializer(), $client->selectDatabase('testing') );, (*13)

// 'my_projection' is the collection that will be used. $repository = $factory->create('my_projector');, (*14)

// If you have a custom read model repository you can use the factory to create your own instances: $repository = $factory->create('my_projector', MyReadModelRepository::class);, (*15)

```, (*16)

Testing

bash $ composer test, (*17)

License

The MIT License (MIT). Please see License File for more information., (*18)

The Versions

22/04 2016

dev-master

9999999-dev

A mongodb driver for Broadway

  Sources   Download

MIT

The Requires

 

The Development Requires

by Madewithlove

cqrs event sourcing broadway projector

22/04 2016

0.2.0

0.2.0.0

A mongodb driver for Broadway

  Sources   Download

MIT

The Requires

 

The Development Requires

by Madewithlove

cqrs event sourcing broadway projector

13/04 2016

0.1.0

0.1.0.0

A mongodb driver for Broadway

  Sources   Download

MIT

The Requires

 

The Development Requires

by Madewithlove

cqrs event sourcing broadway projector