README.md

Midgard2 PHP Content Repository provider

This project implements a Midgard2 -backed provider of the PHP Content Repository (PHPCR) interfaces. phpcr-midgard2 is a fully Jackalope compatible PHPCR provider that can be used in PHP Content Management Systems without requiring Java.

Using Midgard2 instead of Apache Jackrabbit also has the benefit of making interoperability with regular relational databases used by many CMSs easy. Midgard2 supports multiple databases, including MySQL and SQLite.

About PHPCR

The PHP Content Repository API is a PHP version of the Java Content Repository specification. From Wikipedia:

Content Repository API for Java (JCR) is a specification for a Java platform application programming interface (API) to access content repositories in a uniform manner. The content repositories are used in content management systems to keep the content data and also the metadata used in content management systems (CMS) such as versioning metadata.

This way a content management system, for example, would not be tied to a particular database or other storage scheme. Instead, the content repository providers could be chosen based on deployment requirements.

About Midgard2

Midgard2 is an open source content repository library available for multiple programming languages.

Midgard2 is able to access and manage content stored in various common relational databases, including SQLite, MySQL and Postgres. For this, you get a reasonably simple object-oriented interface. An example:

PHPCR and Midgard2

There have been some studies into the conceptual differences and similarities between the Midgard2 Content Repository model and the Java Content Repository model used in PHPCR. Because of these differences, some conceptual mappings are needed.

Repository = Midgard config

Session = Midgard connection

Node = Midgard object

Node Type = MgdSchema

Property = Property or Parameter of Midgard object

Workspace = Midgard workspace

Making the Midgard tree single-rooted

The Midgard PHPCR tree is built out of midgard_node objects. These objects are only used for building the tree, and are connected to the real content objects in the tree by their objectguid property.

Properties that are not managed by MgdSchemas (so, properties not registered to Node Types) are handled by midgard_node_property objects.

How does PHPCR map to your database?

Midgard2 uses standard relational databases for content storage. The PHPCR model is mapped to database tables in the following way:

Tree structure is defined in midgard_node table, which contains name, parent reference, and a reference to a content object

Properties of a node type are stored in the table defined for that node type in its MgdSchema (see examples)

Multivalued properties, and properties not defined in the node type (for example with nt:unstructured) are stored in the midgard_node_property table, which contains name, reference to midgard_node entry, type and value

Binary property contents are stored as files into the blobdir defined in repository configuration

New Node Types can be registered by writing MgdSchemas for them and copying them to Midgard's schema directory (by default /usr/share/midgard2/schema).

Namespace mappings

Projects using PHPCR

Licensing

Content Repositories are important piece of software infrastructure that must be usable by any projects or companies regardless of their business model. Because of this, the Midgard2 PHPCR implementation will be available under permissive terms of the GNU Lesser General Public License.

Development

Contributions to the Midgard2 PHPCR provider are very much appreciated. The development is coordinated on a GitHub repository: