Pomm2-RC1 is out !

Posted 7 years ago.

It is a tremendous news for us. After 6 months of hard work, we are thrilled to announce an almost complete rewrite of Pomm is ready to be used for production purposes. This is an important step for us because this first release candidate means we freeze the features in Pomm2, so what is in the menu ?

What's new since beta2 ?

Embedded entities and composite types converters did appear. Because with Postgresql, creating a table means creating a type, it is possible to create a table with one or several of its fields as type defined by another table. This means it is easily possible to store objects in Postgresql so Pomm2 had to be able to convert embedded entities. When no object oriented entities are needed, one can use the PgComposite converter to convert composite types to PHP associative arrays.

Type hinting for query parameters this is a big one Pomm1 never had. It is now possible to specify query parameters' type directly in the query and Pomm then converts the parameters. Let's see that in slow motion:

Let's say we have an application to book rooms, the room_booking table associates rooms with booking information hence the booking period in the period field. We want to retrieve all RoomBooking entities not booked in one of the dates we want:

$dates = [
    new \DateTime('monday next week noon'),
    new \DateTime('tomorrow 9pm'),
    new \DateTime('2 days ago'),

// select … // from room.room_booking // where not period @> any($1::timestamptz[]) $rooms = $pomm['my_db'] ->getModel('\MyDb\RoomSchema\RoomBookingModel') ->findWhere( "not period @> any($*::timestamptz[])", [$dates] );

Safe projections. Projections look like strange beasts for Pomm's newcomers. This is probably because it is the main difference between Pomm and ORMs. To be short, a projection is the structure of the returned set as described in a SELECT statement (ie the list of returned fields). Model classes do map a flexible entity to a database structure (named a «relation» in set theory language) through a projection. In this last release, the projection has been changed to allow quoting of fields with table alias support. Let's say we want to add a new field to an entity adding the information if yes or no one of its integer field is odd or even:

    public function createProjection()
        return parent::creatProjection()
            ->setField('is_even', '%:int_field:% % 2 = 0', 'bool')

Those acquainted with Pomm's projection notation will spot the change. Field references must now be written as %:field:% to be properly aliased and escaped. All according model's query methods now uses this projection:

// select …, a."int_field" % 2 = 0 as "is_even"
// from public.something a
$iterator = $pomm['my_db']

Default session The Pomm service now defines a default session for those of us who choose not to call a named session builder and be able to change the session in their app in a snap. By default, the default session builder is the first one defined in the configuration. This is easily understandable since most of the applications do use one database connection.

$pomm = new Pomm(['my_database' => ['dsn' => 'pgsql://user/db_name']]);

// return a list of all database schemas $schemas = $pomm ->getDefaultSession() ->getInspector() ->getSchemas() ;

What about now ?

There are two kinds of things to be done now. The first job is our job: write a comprehensive documentation and tutorials, so Pomm2 can see its first release by May or June. The second job is yours: try Pomm. Give us feedback, share your experience through a blog post, send us a twitt. We have made our best so Pomm could fit most of web developers' needs. It seems it easily achieves this goal, we now need to harden it against rough projects where it can shows a real added value. Most of us, Pomm developers have switched for a long time without hassle. But your application has some unique constraints and features that makes it precious to the Pomm's community of users.

Help us to show PHP and Postgresql can give your apps more added value features with more performances.