.. _php-libraries-frameworks-and-tools:

====================================
PHP Libraries, Frameworks, and Tools
====================================

.. default-domain:: mongodb

.. contents:: On this page
   :local:
   :backlinks: none
   :depth: 2
   :class: singlecol

Libraries for the ``mongodb`` Extension
---------------------------------------

Stand-alone Libraries
~~~~~~~~~~~~~~~~~~~~~

- `Mongo Queue PHP <https://github.com/dominionenterprises/mongo-queue-php>`_ is
  a PHP message queue, which uses MongoDB as a backend.

- `Mongo PHP Adapter <https://github.com/alcaeus/mongo-php-adapter>`_ is a
  userland library designed to act as an adapter between applications relying on
  the legacy ``mongo`` extension and the new ``mongodb`` extension. It provides
  the API of the legacy driver on top of the new driver and library, which
  allows for compatibility with PHP 7.

- `Mongodm <https://github.com/purekid/mongodm>`_ is a MongoDB ORM that includes
  support for references, embedded documents, and multilevel inheritance.
  
- `MongoDB Transistor <https://github.com/bjori/mongo-php-transistor>`_:
  Lightweight ODM that utilizes the driver's Persistable interface.

- `Yadm <https://github.com/makasim/yadm>`_ is a MongoDB ODM written for the
  **mongodb** extension. It is schema-less and supports fast object hydration
  and persistence, which makes it well-suited for modeling aggregation results.

Framework Integrations
~~~~~~~~~~~~~~~~~~~~~~

- Drupal

  - `MongoDB integration for Drupal <https://www.drupal.org/project/mongodb>`_.
    This is a collection of several modules which allow sites to store different
    types of Drupal data in MongoDB. Support for the ``mongodb`` extension
    exists for Drupal 8.

- Laravel

  - `Laravel MongoDB <https://github.com/jenssegers/laravel-mongodb>`_: An
    Eloquent model and Query builder with support for MongoDB, using the
    original Laravel API. This library extends the original Laravel classes, so
    it uses exactly the same methods.

  - `laravel-mongo <https://github.com/lindelius/laravel-mongo>`_:  Convenience
    library for working with MongoDB documents in Laravel and the Lumen
    micro-framework. This library is built on top of the official MongoDB PHP
    library and includes an abstract model, a helper class for handling bulk
    writes, database wrappers for Laravel and Lumen, and some necessary helper
    functions.
    
- Symfony

  - `MongoDB Bundle <https://github.com/facile-it/mongodb-bundle>`_: A
    simple bundle service integration for the official `PHP library
    <https://github.com/mongodb/mongo-php-library>`_. Allows you to configure
    connections to different databases or clusters and includes a convenient
    query profiler.
   
- Yii2

  - `MongoDB Extension for Yii 2
    <http://www.yiiframework.com/doc-2.0/ext-mongodb-index.html>`_ provides
    MongoDB integration for Yii framework 2.0.

Libraries for the ``mongo`` Extension
-------------------------------------

Stand-alone Libraries
~~~~~~~~~~~~~~~~~~~~~

- `Doctrine MongoDB ODM <https://github.com/doctrine/mongodb-odm>`_ is a library
  that provides a PHP object mapping functionality for MongoDB. An underlying
  `MongoDB abstraction layer <https://github.com/doctrine/mongodb>`_ exists as
  a separate project. A `Symfony bundle
  <https://github.com/doctrine/DoctrineMongoDBBundle>`_ and `Zend Framework
  module <https://github.com/doctrine/DoctrineMongoODMModule>`_ for the ODM are
  also available. Although it is written for the legacy ``mongo`` extension, it
  is tested to work with the ``mongodb`` extension using `Mongo PHP Adapter
  <https://github.com/alcaeus/mongo-php-adapter>`_.

- `Mongator ODM <https://github.com/mongator/mongator/>`_ is an easy, powerful,
  and ultrafast ODM for PHP and MongoDB. It is a fork of the
  `Mandango ODM <http://mandango.org/>`_.

- `MongoFilesystem <https://github.com/AlexanderMitov/MongoFilesystem>`_
  implements a hierarchical file system using MongoDB as a storage engine. The
  library uses GridFS for storing the files and a standard collection for the
  folder information. There is an object-oriented representation of the folders
  and files in the filesystem and rich API for performing operations. The
  library also implements renderers for JSON, HTML, and XML.

- `Mongofill <https://github.com/mongofill/mongofill>`_ is a pure PHP
  implementation of the ``mongo`` extension, which means that it can be used
  with HHVM. A separate `mongofill-hhvm
  <https://github.com/mongofill/mongofill-hhvm>`_ package provides a `libbson
  <https://github.com/mongodb/libbson>`_ extension for HHVM, which allows for
  more performant BSON encoding and decoding.

- `MongoQueue <https://github.com/lunaru/mongoqueue>`_ is a PHP queue that
  allows for moving tasks and jobs into an asynchronous process for completion
  in the background. The queue is managed by MongoDB.

- `MongoRecord <https://github.com/lunaru/mongorecord>`_ is a PHP MongoDB ORM
  layer built on top of the ``mongo`` PECL extension.

- `PHPMongo ODM <https://github.com/sokil/php-mongo>`_ is an ODM with support
  for validation, relations, events, document versioning, and database
  migrations. Although it is written for the legacy ``mongo`` extension, it is
  tested to work with the ``mongodb`` extension using `Mongo PHP Adapter
  <https://github.com/alcaeus/mongo-php-adapter>`_.

- `Yamop <https://github.com/mawelous/yamop>`_ is yet another MongoDB ODM for
  PHP. It works like the standard MongoDB PHP extension interface but returns
  objects instead of arrays (as ODM). A `Laravel component
  <https://github.com/mawelous/yamop-laravel>`_ is also available.

Framework Integrations
~~~~~~~~~~~~~~~~~~~~~~

- Drupal

  - `MongoDB integration for Drupal <https://www.drupal.org/project/mongodb>`_.
    This is a collection of several modules which allow sites to store different
    types of Drupal data in MongoDB. Support for the ``mongo`` extension exists
    for Drupal 6, 7, and 8.

- Kohana

  - `MangoDB <https://github.com/Wouterrr/mangodb>`_: Mango is an ORM and
    ActiveRecord-like library that takes full advantage of MongoDB's features.

  - `MongoDB PHP ODM <https://github.com/colinmollenhour/mongodb-php-odm>`_ is a
    simple but powerful set of wrappers for using MongoDB in PHP. It is designed
    for use with Kohana 3 but should integrate easily with any PHP
    application.

- Yii 1.x

  - `MongoYii <http://github.com/Sammaye/MongoYii/>`_ is ActiveRecord ORM for
    Yii framework 1.x that supports MongoDB.

  - `Yii MongoDB Driver <https://github.com/fromYukki/Yii-MongoDB-Driver>`_ is a
    MongoDB extension for Yii framework 1.x.

Miscellaneous Projects
~~~~~~~~~~~~~~~~~~~~~~

- `PeclMongoPhpDoc <https://github.com/localgod/PeclMongoPhpDoc>`_ provides
  skeleton classes for the ``mongo`` extension, which may be used to support
  autocomplete and inline documentation for IDEs.
