Codeigniter HMVC and datamapper compatibility Codeigniter HMVC and datamapper compatibility codeigniter codeigniter

Codeigniter HMVC and datamapper compatibility


Firstly a caveat : I have used the HMVC extension but not the Datamapper ORM.

As far as I see it the two extensions have separate goals. In principle I cannot see a conflict.

The HMVC extension is useful where your view is composed of multiple sub-views. It allows you to modularise your application so that your views can be built from the output of multiple controller actions.

The Datamapper ORM allows you to map the data in your database directly onto PHP objects in your application. It saves you the cruft of writing SQL queries to pull rows from a database and hydrate objects in your application. You define what table your model is loaded from and how it is related to the other models in your application. The Datamapper generates the queries to perform the CRUD operations behind the scenes.

HMVC is concerned with how you structure your application. The Datamapper ORM is concerned with how you build your models. I don't see how the Datamapper would stop you using HMVC or vice-versa.


I'd also suggest taking a look at Doctrine ORM. It's a very powerful ORM framework that I've been using for the past year or so in all my CodeIgniter projects and works really well without any compatibility issues or such.

Tutorial for installing Doctrine with CodeIgniter.