Midgard2 PHPCR provider hits 1.0

I'm happy to announce that we were able to release the first stable version of the Midgard2 PHPCR provider yesterday.

Simply put, PHPCR is the future of Midgard's PHP API. Instead of having our own repository APIs, we follow the well-documented and tested PHP Content Repository specification. This allows much better compatibility with other projects, and for example the possibility to choose whether to store contents in Midgard2 or Apache Jackrabbit on per-deployment basis. This obviously doesn't mean that the current Midgard2 API is going away, but just that there is something better and more compatible available on top of that.

PHPCR provides a nice set of capabilities that are either similar to, or surpass the traditional Midgard features:

  • Your content model is constructed out of a tree of Nodes that can contain other Nodes or Properties
  • Properties can be of many different types, including the typical strings and floats, but also binaries (similar to our blobs) and dates
  • Properties can be multivalued (think of multiple images in same property, or a person having multiple emails)
  • Queries can be either constructed with Query Object Model or SQL2
  • Queries support tree constraints (ISDESCENDANTNODE, ISCHILDNODE) and joins
  • Content can be exported and imported via a standard XML format
  • There is a comprehensive Node Type system that allows you to define your content model. The full definitions can be read and introspected via PHP
  • Nodes also support mixins, allowing you to add per-object metadata
  • There are also the unstructured nodes (nt:unstructured) for cases where you don't want to have constraints on what to store and how

On top of PHPCR, there is also a Doctrine ODM that the Midgard2 provider also supports. That gives you more capabilities, like:

Some code examples: https://github.com/bergie/phpcr-midgard2/tree/master/examples

You can see Midgard's test status for both SQLite and MySQL storage back-ends in our Continuous Integration environment: phpcr-midgard2.png

Once you have Midgard2 and our PHP extension available, installation is easy. Add a composer.json file into the root folder of your project:

"require": { "midgard/phpcr": ">=1.0" }

Install with Composer:

$ wget http://getcomposer.org/composer.phar
$ php composer.phar install

Copy MgdSchemas:

$ sudo cp vendor/midgard/phpcr/data/share/schema/* /usr/share/midgard2/schema/
$ sudo cp vendor/midgard/phpcr/data/share/views/* /usr/share/midgard2/views/

...and then just start using the repository in your application. PHPCR can obviously be used side-by-side with traditional Midgard2 or other PHP code.

What will happen next:

  • Support for PHP 5.4 and Postgres (needs work on Midgard2 level)
  • Performance optimization
  • Features work, including versioning
  • More tools for PHPCR. Think of Asgard that would allow you to work with any repositories!
  • PHPCR support built-in for MidCOM and MVC?

For those interested in learning more about PHPCR, there will also be a Paris meetup in mid-January.

Read more Midgard posts.