brokencube/automatorm

This package is abandoned and no longer maintained. No replacement package was suggested.

Simple schema-led ORM, with no code generation required


README

Latest Stable Version Build Status Code Climate

A simple to use ORM in PHP, that reads your database schema directly, without having to run code generators, or create schema documents.

Installation

$ composer require brokencube\automatorm

Requirements

PHP 7.0 + PDO (Currently only MySQL supported - expect to support other engines in the future)

Basic Example

<?php
use Automatorm\Orm\{Model,Schema};
use Automatorm\DataLayer\Database\Connection;

// Class that is linked to the table "blog" - namespace is linked to a particular schema + connection
namespace models {
  class Blog extends Model {}
}

// Get db connection
$connection = Connection::register($pdo); 

// Get db schema for the ORM and assign to 'models' namespace as above
Schema::generate($connection, 'models');  

// Find a table row based on a simple where clause
$blog = Blog::find(['title' => 'My Blog']); // Select * from blog where title = 'My Blog';

echo $blog->id;     // Prints "1"
echo $blog->title;  // Prints "My First Entry"

A more detailed layout of how to use the ORM can be found in the Wiki