PHP content repository API tutorial


I repost some of my blog posts made @ liip. Please see here for the original post and comments:

Our PHP content repository (PHPCR) implementation "Jackalope" is steadily improving. Besides the Jackrabbit backend, there is now also a driver for SQL databases (powered by Doctrine DB abstraction layer) and first work at a MongoDB driver and one for Midgard 1. Midgard 2 will get its own PHPCR implementation not based on Jackalope, and Typo 3 may choose to come back to PHPCR as well. Now is about time to show how to use that API.


PHPCR defines an API to handle semi-structured but hierarchical content in an elegant and consistent way. It combines the best from document-oriented databases (NoSQL) and XML databases (hierarchical trees). Additionally, the API defines search, versioning, access control and other important features.

This is one building block to decouple the cms backend from the frontend. David Nuescheler, the lead of JCR, provides the following advantages of using a content repository

  • Functional Definition of a “Content Repository”

  • Common Vocabulary!

  • No longer learn (dozens of) (ugly) proprietary APIs

  • Write (mostly) portable code, for Document Management, Web Content Management, Source Code Control

  • Compare Repository Functionality

  • No more information silos and vendor Lock-in Content-Centric Infrastructure

A remark for the people interested in the Symfony Content Management Framework initiative: For the CMF you do not need to know how to code PHPCR. There is the Doctrine PHPCR-ODM layer that provides Document classes for yourcontent repository just as the Doctrine ORM abstracts from SQL databases. However, if you want to help us developping the CMF, you should look into the tutorial.


I wrote a tutorial that shows how to use PHPCR and explains how to install a playground to experiment with. The API is really simple to use and very expressive for hierarchical but flexible content. After the tutorial, you can take a look at the API documentation and at the full JCR specification.

I am happy to hear your feedback on this tutorial or the whole topic of content repositories.

phpcr php content repository