Skip to content

A micro framework for create a very simple decoupled ORM (sqlite, mysql, postgres, sqlserver)

License

Notifications You must be signed in to change notification settings

byjg/php-micro-orm

Repository files navigation

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

Related Projects

Dependencies

flowchart TD
    byjg/micro-orm --> byjg/anydataset-db
    byjg/micro-orm --> ext-json

Open source ByJG

About

A micro framework for create a very simple decoupled ORM (sqlite, mysql, postgres, sqlserver)

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages