PHP ORM or something like it
I don’t want to deal with SQL statements anymore when writing applications that need data persistence. I’m really impressed with how Rails does this cleanly, and I also like the idea behind POJOs. I want to be able to do something like the following in my application:
$user = User::from($_POST);
$user->create();
To retrieve, update and delete records:
$keys = array('username' => 'noodlehaus');
$user = User::find($keys);
$user->password = 'secret123';
$user->update();
$user->delete();
The recipe would be perfect if the declaration for this class is as simple as:
class User extends Base {
..public $username;
..public $password;
}
Based on these code snips, I’m laying out the following baselines for data persistence:
- Only work on supporting MySQL (at least initially, or until i need to use another database)
- SQL statements should only exist in Base
- VERY limited support for operations and relationships (create, update, find, delete, 1-1, 1-*, *-*)
These will be enough for now. If something important pops up or something that makes great sense to add, I’ll just do them, as nothing’s set in stone.
Rolling yet another PHP framework
I’ve been searching for PHP frameworks lately and looked into some of the popular ones (Zend, Cake, Symfony, Kohana, CodeIgniter, Akelos). Other than those, I also came across Recess, a relatively new restful PHP framework that’s not trying to port rails to PHP. Recess appealed to me the most, but like the others I mentioned, still did too much for me.
Frameworks have to be usable for different use cases thus the elaborate libraries, but somehow this is what’s turning me off. What I wanted was something really simple and in between – not so high-level and too layered, and not so low level and repetetive. The solution? I’ll try to roll my own.
Yes, another framework that will do things other frameworks are already doing. I don’t really care. I’m doing this to learn, and to cater to my own needs. If while working on it I find that it could be useful for other people, maybe I’ll release it, maybe I won’t.