2017 © Pedro Peláez
 

library monga

MongoDB Abstraction Layer

image

devitek/monga

MongoDB Abstraction Layer

  • Monday, September 25, 2017
  • by CaporalDead
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1,061 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 32 Forks
  • 0 Open issues
  • 23 Versions
  • 32 % Grown

The README.md

Monga

Latest Version on Packagist ![Software License][ico-license] Build Status ![Total Downloads][ico-downloads], (*1)

A simple and swift MongoDB abstraction layer for PHP 5.4+, (*2)

What's this all about?

  • An easy API to get connections, databases and collections.
  • A filter builder that doesn't make your mind go nuts.
  • All sorts of handy update functions.
  • An abstraction for sorting single results.
  • GridFS support for a Mongo filesystem.
  • Easy aggregation and distinct values.

Vision

Monga was created with the acknowledgment of the MongoDB PHP package already being pretty awesome. That's why in a lot of cases Monga is just a simple wrapper around the MongoDB classes. It provides some helpers and helps you set up queries using a query builder. Which you can also choose not to use! Everything will still work accordingly. During the development, a lot of planning has gone into creating a nice streamlined API that closely follows the MongoDB base classes, while complementing existing query builders for SQL-like databases., (*3)

Install

Via Composer, (*4)

``` bash $ composer require league/monga, (*5)


## Usage ```php use League\Monga; // Get a connection $connection = Monga::connection($dns, $connectionOptions); // Get the database $database = $connection->database('db_name'); // Drop the database $database->drop(); // Get a collection $collection = $database->collection('collection_name'); // Drop the collection $collection->drop(); // Truncate the collection $collection->truncate(); // Insert some values into the collection $insertIds = $collection->insert([ [ 'name' => 'John', 'surname' => 'Doe', 'nick' => 'The Unknown Man', 'age' => 20, ], [ 'name' => 'Frank', 'surname' => 'de Jonge', 'nick' => 'Unknown', 'nik' => 'No Man', 'age' => 23, ], ]); // Update a collection $collection->update(function ($query) { $query->increment('age') ->remove('nik') ->set('nick', 'FrenkyNet'); }); // Find Frank $frank = $collection->findOne(function ($query) { $query->where('name', 'Frank') ->whereLike('surname', '%e Jo%'); }); // Or find him using normal array syntax $frank = $collection->find([ 'name' => 'Frank', 'surname' => new MongoRegex('/e Jo/imxsu') ]); $frank['age']++; $collection->save($frank); // Also supports nested queries $users = $collection->find(function ($query) { $query->where(function ($query) { $query->where('name', 'Josh') ->orWhere('surname', 'Doe'); })->orWhere(function ($query) { $query->where('name', 'Frank') ->where('surname', 'de Jonge'); }); }); // get the users as an array $arr = $users->toArray();

Aggregation

A big part of the newly released MongoDB pecl package is aggregation support. Which is super easy to do with Monga:, (*6)

$collection->aggregate(function ($a) {
    $a->project([
        'name' => 1,
        'surname' => -1,
        'tags' => 1,
    ])->unwind('tags');

    // But also more advanced groups/projections
    $a->project(function ($p) {
        $p->select('field')
            ->select('scores')
            ->exclude('other_field');
    })->group(function ($g) {
        $g->by(['$name', '$surname'])
            ->sum('scores');
    });
});

Contributing

Please see CONTRIBUTING and CONDUCT for details., (*7)

Security

If you discover any security related issues, please email bryan@bryan-crowe.com instead of using the issue tracker., (*8)

Credits

License

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

The Versions

25/09 2017

dev-master

9999999-dev https://github.com/thephpleague/monga

MongoDB Abstraction Layer

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Frank de Jonge

mongodb

20/09 2017

1.3.1

1.3.1.0 https://github.com/thephpleague/monga

MongoDB Abstraction Layer

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Frank de Jonge

mongodb

19/09 2017

1.3.0

1.3.0.0 https://github.com/thephpleague/monga

MongoDB Abstraction Layer

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Frank de Jonge

mongodb

29/02 2016

1.2.4

1.2.4.0 https://github.com/thephpleague/monga

MongoDB Abstraction Layer

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Frank de Jonge

mongodb

08/12 2015

1.2.3

1.2.3.0 https://github.com/thephpleague/monga

MongoDB Abstraction Layer

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Frank de Jonge

mongodb

20/11 2015

1.2.2

1.2.2.0 https://github.com/thephpleague/monga

MongoDB Abstraction Layer

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Frank de Jonge

mongodb

11/10 2015

1.2.1

1.2.1.0 https://github.com/thephpleague/monga

MongoDB Abstraction Layer

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Frank de Jonge

mongodb

22/09 2015

1.2.0

1.2.0.0 https://github.com/thephpleague/monga

MongoDB Abstraction Layer

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Frank de Jonge

mongodb

15/02 2015

1.1.0

1.1.0.0 https://github.com/thephpleague/monga

MongoDB Abstraction Layer

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Frank de Jonge

mongodb

12/02 2015

1.0.6

1.0.6.0 https://github.com/thephpleague/monga

MongoDB Abstraction Layer

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

by Frank de Jonge

mongodb

29/10 2014

1.0.5

1.0.5.0 https://github.com/thephpleague/monga

MongoDB Abstraction Layer

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

by Frank de Jonge

mongodb

23/10 2014

1.0.4

1.0.4.0 https://github.com/php-loep/monga

MongoDB Abstraction Layer

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

by Frank de Jonge

mongodb

22/11 2013

1.0.3

1.0.3.0 https://github.com/php-loep/monga

MongoDB Abstraction Layer

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

by Frank de Jonge

mongodb

18/08 2013

1.0.2

1.0.2.0 https://github.com/php-sbfc/monga

MongoDB Abstraction Layer

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

by Frank de Jonge

mongodb

12/04 2013

1.0.1

1.0.1.0 https://github.com/php-sbfc/monga

MongoDB Abstraction Layer

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

by Frank de Jonge

mongodb

11/04 2013

1.0.0

1.0.0.0 https://github.com/php-sbfc/monga

MongoDB Abstraction Layer

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

by Frank de Jonge

mongodb

14/03 2013

0.2.3

0.2.3.0 https://github.com/FrenkyNet/Monga

MongoDB Abstraction Layer

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

by Frank de Jonge

mongodb

03/03 2013

0.2.1

0.2.1.0 https://github.com/FrenkyNet/Monga

MongoDB Abstraction Layer

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

by Frank de Jonge

mongodb

07/12 2012

0.2.0

0.2.0.0 https://github.com/FrenkyNet/Monga

MongoDB Abstraction Layer

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

by Frank de Jonge

mongodb

20/11 2012

0.1.3

0.1.3.0 https://github.com/FrenkyNet/Monga

MongoDB Abstraction Layer

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

by Frank de Jonge

mongodb

16/11 2012

0.1.2

0.1.2.0 https://github.com/FrenkyNet/Monga

MongoDB Abstraction Layer

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

by Frank de Jonge

mongodb

16/11 2012

0.1.1

0.1.1.0 https://github.com/FrenkyNet/Monga

MongoDB Abstraction Layer

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

by Frank de Jonge

mongodb

15/11 2012

0.1.0

0.1.0.0 https://github.com/FrenkyNet/Monga

MongoDB Abstraction Layer

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

by Frank de Jonge

mongodb