/mongolid

Easy, powerful and ultrafast ODM for PHP and MongoDB

Primary LanguagePHPMIT LicenseMIT

Mongolid ODM for MongoDB (PHP7)

Easy, powerful and ultrafast ODM for PHP7 build on top of the new mongodb driver.

Mongolid

Mongolid supports both ActiveRecord and DataMapper patterns. You choose! (:

Codacy Badge StyleCI Latest Stable Version Total Downloads Latest Unstable Version License

SensioLabsInsight

Introduction

Mongolid ODM (Object Document Mapper) provides a beautiful, simple implementation for working with MongoDB. Each database collection can have a corresponding "Model" which is used to interact with that collection.

Note: If you are working with Laravel, take a look at mongolid-laravel repository.

Installation

You can install library through Composer:

$ composer require leroy-merlin-br/mongolid

Requirements

Note: If you are looking for the old PHP 5.x version, head to the v0.8 branch.

Mongolid Docs

Troubleshooting

"PHP Fatal error: Class 'MongoDB\Client' not found in ..."

The MongoDB\Client class is contained in the new MongoDB driver for PHP. Here is an installation guide. The driver is a PHP extension written in C and maintained by MongoDB. Mongolid and most other MongoDB PHP libraries utilize it in order to be fast and reliable.

"Class 'MongoDB\Client' not found in ..." in CLI persists even with MongoDB driver installed.

Make sure that the php.ini file used in the CLI environment includes the MongoDB extension. In some systems, the default PHP installation uses different .ini files for the web and CLI environments.

Run php -i | grep 'Configuration File' in a terminal to check the .ini that is being used.

To check if PHP in the CLI environment is importing the driver properly run php -i | grep -i 'mongo' in your terminal. You should get output similar to:

$ php -i | grep -i 'mongo'
MongoDB support => enabled
MongoDB extension version => 1.2.8
MongoDB extension stability => stable
libmongoc bundled version => 1.5.5

"This package requires php >=7.0 but your PHP version (X.X.X) does not satisfy that requirement."

The new (and improved) version 2.0 of Mongolid requires php7. If you are looking for the old PHP 5.x version, head to the v0.8 branch.

License

Mongolid is free software distributed under the terms of the MIT license

Additional information

Mongolid was proudly built by the Leroy Merlin Brazil team. See all the contributors.

Any questions, feel free to contact us.

Any issues, please report here