Blog Posts

PHP talking to Magnolia CMS

Since we started working on Jackalope, we always claimed it would also provide an integration point with other enterprise systems. Last week, we set out to proof this idea. Grégory Joseph of the Java based Magnolia CMS came to help us on the Magnolia side of things. Magnolia is using the JCR reference implementation Jackrabbit for storing its content. After an interesting exchange on their design decisions and our ideas, we started to hack.

Trying to import an XML export from Magnolia in the JCR standard format showed that the Jackalope importer is not yet perfect. In the end Greg was faster in building a Magnolia module that exposes the Jackrabbit Davex binding that Jackalope uses to communicate with the server.

After that, things really started flowing. We managed to not only read data, but also write using the frontend editing feature of the CMF. Additionally, we managed to configure PHPCR-ODM to determine document classes based on the MetaData child every Magnolia page node has. And all of that using several parallel connections to the repositories, so that the normal pages and navigation can still be loaded from our standalone jackrabbit backend (you could just as well use another PHPCR implementation like jackalope-doctrine).

All in all a very successful hackday. We integrated the demos into the cmf-sandbox (branch magnolia_integration). See the MagnoliaController in src/Sandbox/MagnoliaBundle/Controller.

Screencapture showing the edit functionality

Installing the Sandbox with Magnolia

If you want to try things out for yourself, you need to:

  • Download Magnolia Community Edition
  • unpack it into a folder
  • Download the Magnolia Jackrabbit-Davex Module and drop all .jar files from this archive into apache-tomcat-6.0.32/webapps/magnoliaAuthor/WEB-INF/lib/
  • edit apache-tomcat-6.0.32/conf/server.xml to change the port from the default 8080 to 8888, so it looks something like <connector port="8888" protocol="HTTP/1.1">...
  • remove open file limitations. in bash, this will be ulimit -n 5000
  • launch magnolia with something like this: apache-tomcat-6.0.32/bin/magnolia_control.sh start tail -f apache-tomcat-6.0.32/logs/catalina.out
  • visit localhost:8888 and follow the Magnolia installation (login with superuser/superuser)

If you followed the above steps, you should be able to access Magnolia data with Jackalope-Jackrabbit at http://localhost:8888/magnoliaAuthor/.davex/ (Note that there is no web browser access, as the servlet does not issue a basic auth challenge but just expect the credentials to be set from the beginning).

Now try the urls /magnolia_edit, /magnolia/about/subsection-articles/article and /magnolia_odm and read the code to see what we do.

Related Entries:
- Jackalope and Magnolia CMS: Recording online, questions and answers
- Progress on PHPCR with a hackday
- prismic.io content repository as a service
- Content storage done right
- Announcement: PHPCR and Magnolia CMS: Bridging the PHP and Java Worlds

About the author


Find more about him on Twitter, Google+ and his personal site.

Comments [7]

Lukas, 09.05.2012 12:43 CET

What was kind of cool is that as while we were showing Greg the PHP code, he immediately recognized the JCR API behind all of this.

daniele, 18.07.2012 14:57 CET

is there a simple way to interact with magnolia using php and write/read from jcr? Some code? Thank you

Lukas, 18.07.2012 16:37 CET

Well it is as "simple" currently as described above.

1) enable davex support in Magnolia
2) setup PHPCR with Jackalope and the Jackrabbit transport
3) interact with Magnolia with read/write support from PHP in an API that is very similar to JCR (http://phpcr.github.com/)

Note we will give a presentation on this at the Magnolia Conference in early September.

daniele, 19.07.2012 09:23 CET

your help is very appreciated, thank you :-)

Lukas, 09.09.2012 15:07 CET

I have updated the branch to match the latest versions of the sandbox as part of the presentation I held at the Magnolia Conference:
http://www.magnolia-cms.com/community/magnolia-conference.html

Lukas, 17.09.2012 10:38 CET

I have now unbundled the examples from Symfony2 CMF and created a dedicated repository to get started:
https://github.com/liip/PHPCR-and-Magnolia

david, 21.01.2013 22:33 CET

Updated the link to the magnolia jackrabbit module: http://liip.to/magnoliajackrabbit

Add a comment

Your email adress will never be published. Comment spam will be deleted!