Skip to main content

MicroOrm for PHP

Build Status Opensource ByJG GitHub source GitHub license GitHub release

A micro framework for create a very simple decoupled ORM. This library intended to be very small and very simple to use;

Key Features:

  • Can be used with any DTO, Entity, Model or whatever class with public properties or with getter and setter
  • The repository support a variety of datasources: MySql, Sqlite, Postgres, MySQL, Oracle (see byjg/anydataset)
  • A class Mapper is used for mapping the Entity and the repository
  • Small and simple to use

Architecture

These are the key components:

┌──────────────────────────┐
│ Repository │ ┌─────────────────────┐
│ │ ┌────│ Model │
│ │ │ └─────────────────────┘
│ ┌───────────────┴─────┐ │ │
│ │ Mapper │───┤ │
│ └───────────────┬─────┘ │ │
│ │ │ │ ┌─────────────────────┐
│ │ │ └────│ FieldMapping │
│ │ │ └─────────────────────┘
│ │ │
│ ┌───────────────┴─────┐
│ │ Query │
│ └───────────────┬─────┘
│ │
│ ┌───────────────┴─────┐
│ │ DbDriverInterface │───────────────┐
│ └───────────────┬─────┘ │
│ │ │
└──────────────────────────┘ .─────────.
│ │
│`─────────'│
│ │
│ DB │
│ │
│ │
`─────────'
  • Model is a get/set class to retrieve or save the data into the database
  • Mapper will create the definitions to map the Model into the Database.
  • Query will use the Mapper to prepare the query to the database based on DbDriverInterface
  • DbDriverIntarce is the implementation to the Database connection.
  • Repository put all this together

Basics

Advanced Topics

Install

Just type:

composer require "byjg/micro-orm"

Running Tests

./vendor/bin/phpunit

Dependencies


Open source ByJG