Thoughts, ideas, random notes, ramblings...

Sometimes serious, sometimes with a big wink. But always about FuelPHP!

Future of the ORM

Building an Object Relation Mapper (ORM) is no small feat. It is large enough to warrant being a an entire project or framework in its own right given the large desirable feature set. Given that, I thought it a good idea to outline what the plans and direction are for the new FuelPHP ORM as we have lots of improvements and features for you to make use of.

Under the hood

With the v1 orm the main logic of the orm was contained in the Model class. For v2 we will be splitting this all out into its component parts. Spreading out the logic means the code is cleaner, easier to test and much easier to extend.

Probably the biggest change in v2 is the fact that Models will be dumb data containers. The Models themselves will contain as little logic as possible and will rely on the rest of the infrastructure to provide the main logic. This means that you can handle more models in memory and work easily with large data sets, which was a limitation in the v1 ORM.

The core of the new ORM will reside in two types of classes. Providers and Queries. Providers contain the definition of an entity. This is its properties, table name, primary key config, relations, observers, any information that is used to define an entity and its information. A Query object plays a similar role to the Query object from the v1 ORM. It is responsible for loading data from the Database Access Layer (DBAL).

Please note, this reflects the current state of the v2 ORM at the time of writing. It is possible that the structure will change as the functionality of the ORM grows.

The current aim

Currently for the v2 alpha release in the new year we are looking at having a basic activerecord style implementation. The aim is that this will provide a basic starting point with fieldset, validation, observers and a sane interface to be able to manage the underlying structures easily so you can get started with the new ORM and we can try out the infrastructure and get a feel for how it all works, as well as gathering feedback for improvements and of course, bug reports.

This stage will also introduce a concept called “ModelCollections”, this is an object that will encapsulate one or more models to allow mass operations to be optimized later on.

Future plans

Looking forward we will also be introducing everything that the previous ORM had, relations, soft, temporal, nested sets and EAV. In addition to this we will also be adding the ability to create relations between multiple data sources and another big feature we want to support is Codeception integration to be able to easily mock models for testing.

In the far future we are looking at implementing an automatic CRUD generation to allow things like admin panels to be constructed quickly, but this is a post for another time.

The new ORM is available right now for you to use but should be considered in pre-alpha state. You can find the code over at GitHub and is available at Packagist. The ORM currently has minimal dependencies and is tested to run on HHVM and like the rest of v2 is PHP +5.5.

Please check the ORM wiki for the latest documentation.

If you have any questions then feel free to contact “uru” on freenode in the #fuelphp channel or email uru@fuelphp.com


Tags: orm

Share This Post:

Disqus Comments

comments powered by Disqus

Search

Latest posts

Latest posts
  • @Steve West (uru) 01/01/2015
    V2 Alpha 1 release!
    The first v2 alpha is finally here!
  • @Steve West (uru) 11/11/2014
    Future of the ORM
    Building an Object Relation Mapper (ORM) is no small feat.…
  • @Steve West (uru) 03/11/2014
    First v2 Alpha

    FuelPHP v2 has been “on the horizon” or “just…

Aura Theme © 2014 by PI-Themes Website © 2014 -2017 FuelPHP