Skip to content

a straightforward, unopinionated php modelling library

Notifications You must be signed in to change notification settings

bchubb-web/represent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

represent

a simple unopinionated modelling library, allowing you to 'represent' your data in a usable, logical way while giving you the power to handle your data however you want.

Installation

To install require the package to your project with composer

composer require bchubbweb/represent

Usage

To create a model extend the Model class, and define any custom properties or methods you need.

<?php

use Bchubbweb\Represent\Model;

class User extends Model
{
    ...
}

Then you can generate an instance, which returns a new instance of the model.

Represent does not create any persistant data, it is up to you to handle the data in whatever way you wish, but using some of our helper functions can make this easier for you.

<?php

use Bchubbweb\Represent\Model;

$user = new User([
    'name' => 'Bob',
    'email' => 'bob@btinternet.com',
]);
$sql = $user->toSql(); // INSERT INTO users (name, email) VALUES ('Bob', 'bob@btinternet.com');

When a model is updated, the result of the toSql method will return an update statement, reflecting the changes made to the instance.

About

a straightforward, unopinionated php modelling library

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages