2017 © Pedro Peláez
 

library silex-simplemongo-provider

Simple mongdb provider for Silex2

image

exs/silex-simplemongo-provider

Simple mongdb provider for Silex2

  • Wednesday, October 12, 2016
  • by rumpranger
  • Repository
  • 7 Watchers
  • 0 Stars
  • 10 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

EXS-silex-simplemongo-provider

A simple Silex provider to persist and execute queries on MongDB database on php7, (*1)

Installing the EXS-silex-simplemongo-provider in a Silex project

Open the composer.json file and add the EXS-silex-simplemongo-provider as a dependency: ``` js //composer.json //... "require": { //other bundles "exs/silex-simplemongo-provider": "^1.0", (*2)

Save the file and have composer update the project via the command line:
``` shell
php composer.phar install

Or you could just add it via the command line:, (*3)

$ composer.phar require exs/silex-simplemongo-provider

Update the app.php to include EXS-silex-simplemongo-provider: ``` php //app.php //... $app->register(new \EXS\SimpleMongoProvider\Providers\Services\SimpleMongoProvider());, (*4)

Update your mongodb connection and environment in your config.php:
```php
//...
$app['mongo.connections'] = array(
    'connection' => 'mongodb://localhost:27017',
    'dbname' => 'DB_NAME'
);
//...

USAGE

Register the service in your service provider ``` php public function register(Container $container) { $container[YOUR_SERVICE_NAME] = ( function ($container) { return new YOUR_SERVICE( $container['exs.serv.mongo'] );
}); }, (*5)


In your service ```php public function __construct(\EXS\SimpleMongoProvider\Services\SimpleMongoService $mongo_service) { $this->mongo_service = $mongo_service; } . . . // Insert $this->mongo_service->persist(YOUR_CLASS_OR_ARRAY); $result = $this->mongo_service->flush(COLLECTION_NAME); // the result will store the number of inserted entries or error message if(!is_int($result) || $result == 0) { throwException($result); } // Update $filter = ['product' => 6]; $this->mongo_service->update($filter, YOUR_CLASS_OR_ARRAY); $result = $this->mongo_service->flush(COLLECTION_NAME); // Get data with query $filter = ['product' => 6]; $option = ['projection' => ['_id' => 0]]; $result = $$this->mongo_service->exeQuery($filter, $option, COLLECTION_NAME); // $result will contain results in an array

Contributing

Anyone and everyone is welcome to contribute., (*6)

If you have any questions or suggestions please [let us know][1]., (*7)

The Versions

12/10 2016

dev-master

9999999-dev https://github.com/ExSituMarketing/EXS-silex-simplemongo-provider

Simple mongdb provider for Silex2

  Sources   Download

MIT

The Requires

 

by slee

mongodb silex provider

12/10 2016

v1.0.0

1.0.0.0 https://github.com/ExSituMarketing/EXS-silex-simplemongo-provider

Simple mongdb provider for Silex2

  Sources   Download

MIT

The Requires

 

by slee

mongodb silex provider

11/10 2016

v0.0.1

0.0.1.0 https://github.com/ExSituMarketing/EXS-silex-simplemongo-provider

Simple mongdb provider for Silex2

  Sources   Download

MIT

The Requires

 

by slee

mongodb silex provider