This branch is the latest stable branch of Pomm.
Pomm is a lightweight, fast, efficient and powerful PHP object manager for the Postgresql relational database. Pomm is not an ORM, it is an object oriented framework for Postgresql in PHP implementing the identity map design pattern and proposing convenient functionalities. Dropping the abstraction layer makes programmers able to take advantage of most of Postgresql's awesome features.
Pomm 1.2 works with PHP 5.3 and Postgresql 9.0 and above.
You can reach
- Database introspection and model generation
- Lazy hydration and on the fly type conversion
- SQL queries, virtual fields, finders and pagers
- Collection, filters and query filters
- A Where clause builder
- Security and debugging tools
Once you have designed your database using your favorite tool, Pomm can generate PHP model classes for you by inspecting tables and views. It checks the schema where your database objects are stored so generated classes use according PHP namespaces, there will not be naming collision anymore ! Of Course, Postgresql's table inheritance is supported.
Queries return collections which are scrollable iterators on results. Fetched objects are hydrated on demand for minimal memory consumption and data are converted from/to Postgresql. Boolean in Pg are boolean in PHP, arrays in Pg are arrays in PHP, geometric types are converted into geometric PHP objects. Of course this is extensible and custom database types can be converted into custom PHP classes. Almost all standard and geometric types are supported plus range, HStore and ltree extensions.
Of course 80% of the queries of a web applications are like SELECT * FROM my_table WHERE ...
So there is a method for that. You can configure what you do want in the select fields in case you would like to add your classes extra properties. You can even use them with the converter system with extra fields adding them as virtual fields. For the more complicated queries, SQL is the way to go. You can use all the awesome operators, full text search, window functions, CTEs and recursive queries, (add your preferred feature here).
Sometimes, you want to create a WHERE
clause dynamically. Pomm proposes a Where class to let you AND
and/or OR
your conditions passing the values as argument each time for escaping. There is even a WhereIn
method with an array of values as parameter.
All queries are prepared and pooled so they are re used if you send twice the same query with different parameters. The values passed as argument are automatically escaped by the server. Furthermore, the converter system ensures there is no type enforcing.
Pomm 1.2 can uses any PSR-3 compatible logger (ie Monolog <https://github.com/Seldaek/monolog>).
Using composer installer and autoloader is probably the easiest way to install Pomm and get it running. What you need is just a composer.json
file in the root directory of your project:
{ "require": { "pomm/pomm": "master-dev" } }
Invoking composer.phar
will automagically download Pomm, install it in a vendor
directory and set up the according autoloader.
- Silex PommServiceProvider
- Symfony2 PommBundle
With Silex, it is possible to bootstrap a kitchen sink using this gist <https://gist.github.com/chanmix51/3402026>, in an empty directory just issue the command:
wget -O - 'https://gist.github.com/chanmix51/3402026/raw/3cf2125316687be6d3ab076e66f291b68b422ce7/create-pomm-silex.sh' | bash
And follow the instructions.
That's very easy with github:
- Send feedback to @PommProject on twitter or by mail at <hubert DOT greg AT gmail DOT com>
- Report bugs (very appreciated)
- Fork and PR (very very appreciated)
- Send vacuum tubes to the author (actual preferred are russians 6Φ12Π, 6Ж43Π, 6Ж38Π, 6C19Π)
psql -c 'CREATE DATABASE pomm_test' -U postgres -h 127.0.0.1
psql -c 'CREATE EXTENSION hstore' -U postgres -h 127.0.0.1 pomm_test
psql -c 'CREATE EXTENSION ltree' -U postgres -h 127.0.0.1 pomm_test
phpunit --configuration tests/phpunit.travis.xml