Creating an ORM for PHP and would like some input
Posted: Mon Aug 03, 2009 4:56 pm
Hi!
(This is my first post here, so bear with me
)
I'm creating an Object-Relational-Mapper for PHP as a school project (it affects my grade etc. but it is permitted to be open source) and I've come quite a long way on it.
But I'm still not sure I'm going in the correct direction with it, as there is so much which can be done (Just look at Doctrine or something similar).
The reason I'm creating my own ORM is because I want something which is easy to use, fast (both in terms of developing with it and in terms of performance),
secure (ie. escape and the usual stuff) and flexible.
I've decided to use PHP 5.2, as 5.3 is going to take some time (I really want to use 5.3, but I think it may be an overkill in most areas
(I know ... closures are really nice)), and it also shouldn't require any external dependencies except for the database extension for the server the user is going to use.
Current status:
- DataMapper which maps plain PHP objects (only requires public properties)
- Database Abstraction (I'm not using PDO, as it is harder to cache and also slower if I try to add my own methods to the result objects, objections with motivations welcome
)
- Multiple database connections (with support for write rerouting, eg. for master-slave databases)
- Query builder (for SELECT, INSERT, UPDATE and DELETE
- Code generator for specialized mappers (for speed and avoids complex dynamic methods), transparently generates the mapper
- Relations (Has One, Has Many, Belongs To, Has And Belongs To Many (HABTM))
- Eager loading (explicitly defined/called)
- Related objects aren't loaded automatically, instead it forces the user to utilize a method call to load them (this is good, because the user realizes that it issues a query)
- JOINs (eager loading) of related records can be performed in almost infinite levels (wonder when it is becoming too much for PHP to process, though)
- Configuration written in PHPdoc (will support other configurations as well, but I like the PHPdoc because it stores the configuration in the mapped object without interfering)
Things I later will add:
- Table builder
- Mapping with getters/setters
- Transactions (need to be finished with the save() method, as I will use transactions for it as it saves relations too)
- Unit of Work
I've been developing this for a few months, and when I started I did not have a "great" knowledge of Design Patterns
(That means I will rewrite a lot of the base, which I wrote early on).
So what I would like is some feedback on my decisions and also some input about what you think makes a great Object-Relational-Mapper.
Thanks!
PS. I will hopefully have a website with a forum, manual, download etc. up quite soon (a month or two, I hope it won't be longer).
(This is my first post here, so bear with me
I'm creating an Object-Relational-Mapper for PHP as a school project (it affects my grade etc. but it is permitted to be open source) and I've come quite a long way on it.
But I'm still not sure I'm going in the correct direction with it, as there is so much which can be done (Just look at Doctrine or something similar).
The reason I'm creating my own ORM is because I want something which is easy to use, fast (both in terms of developing with it and in terms of performance),
secure (ie. escape and the usual stuff) and flexible.
I've decided to use PHP 5.2, as 5.3 is going to take some time (I really want to use 5.3, but I think it may be an overkill in most areas
(I know ... closures are really nice)), and it also shouldn't require any external dependencies except for the database extension for the server the user is going to use.
Current status:
- DataMapper which maps plain PHP objects (only requires public properties)
- Database Abstraction (I'm not using PDO, as it is harder to cache and also slower if I try to add my own methods to the result objects, objections with motivations welcome
- Multiple database connections (with support for write rerouting, eg. for master-slave databases)
- Query builder (for SELECT, INSERT, UPDATE and DELETE
- Code generator for specialized mappers (for speed and avoids complex dynamic methods), transparently generates the mapper
- Relations (Has One, Has Many, Belongs To, Has And Belongs To Many (HABTM))
- Eager loading (explicitly defined/called)
- Related objects aren't loaded automatically, instead it forces the user to utilize a method call to load them (this is good, because the user realizes that it issues a query)
- JOINs (eager loading) of related records can be performed in almost infinite levels (wonder when it is becoming too much for PHP to process, though)
- Configuration written in PHPdoc (will support other configurations as well, but I like the PHPdoc because it stores the configuration in the mapped object without interfering)
Things I later will add:
- Table builder
- Mapping with getters/setters
- Transactions (need to be finished with the save() method, as I will use transactions for it as it saves relations too)
- Unit of Work
I've been developing this for a few months, and when I started I did not have a "great" knowledge of Design Patterns
(That means I will rewrite a lot of the base, which I wrote early on).
So what I would like is some feedback on my decisions and also some input about what you think makes a great Object-Relational-Mapper.
Thanks!
PS. I will hopefully have a website with a forum, manual, download etc. up quite soon (a month or two, I hope it won't be longer).