2017 © Pedro Peláez
 

library leaf-orm

A super light ORM-ish library for using MongoDB with PHP

image

eman-development-design/leaf-orm

A super light ORM-ish library for using MongoDB with PHP

  • Friday, June 1, 2018
  • by eman-development-design
  • Repository
  • 1 Watchers
  • 2 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Leaf-Orm

A super light ORM-ish library for using MongoDB with PHP, (*1)

This package has been depreciated, the new library to use is MongoDB Helpers

Requirement

  • PHP 7.1 or newer
  • MongoDB Extension 1.1 or newer

Installation

composer require eman-development-design/Leaf-Orm, (*2)

Usage

There's two simple items, a model and a repository object., (*3)

Model

Consider the example below:, (*4)

use MongoDB\BSON\Serializable;
use MongoDB\Model\BSONDocument;
use Leaf\Model\MongoModel

class User implements Serializable, MongoModel
{
    public $userGuid;
    public $email;
    public $firstName;
    public $lastName;

    public function bsonSerialize() : array
    {
        return [
            'UserGuid' => $this->userGuid,
            'Email' => $this->email,
            'FirstName' => $this->firstName,
            'LastName' => $this->lastName
        ];
    }

    public function map(BSONDocument $document)
    {
        $this->userGuid = $document['UserGuid'];
        $this->email = $document['Email'];
        $this->firstName = $document['FirstName'];
        $this->lastName = $document['LastName'];
    }

    public function toArray() : array
    {
        return [
            'UserGuid' => $this->userGuid,
            'Email' => $this->email,
            'FirstName' => $this->firstName,
            'LastName' => $this->lastName
        ];
    }
}

map will take a BSON Document and populate the model., (*5)

toArray will convert your model to an array., (*6)

Repository

MongoRepository is used for your repository layer, it only has one method, which is a way to fetch a collection., (*7)

Bugs, Suggestions

Fill out an issue ticket to report any issues or to suggest ideas to make this library better., (*8)

Contribute

I welcome people who wish to contribute to this project, just create a pull request and I'll review all the changes., (*9)

The Versions

01/06 2018

dev-master

9999999-dev http://emandevelopmentdesign.com

A super light ORM-ish library for using MongoDB with PHP

  Sources   Download

MIT

The Requires

 

by Ed Lomonaco

orm mongodb mongo

25/04 2018

1.0.1

1.0.1.0 http://emandevelopmentdesign.com

A super light ORM-ish library for using MongoDB with PHP

  Sources   Download

MIT

The Requires

 

by Ed Lomonaco

orm mongodb mongo

13/04 2018

1.0.0

1.0.0.0 http://emandevelopmentdesign.com

A super light ORM-ish library for using MongoDB with PHP

  Sources   Download

MIT

The Requires

 

by Ed Lomonaco

orm mongodb mongo