Skip to content

rambo/phpcr-midgard2

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Midgard2 PHP Content Repository provider

This project attempts to implement a Midgard2 -backed implementation of the PHP Content Repository (PHPCR) interfaces. The plan is to have 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.

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.

There is currently discussion about including PHPCR APIs into the Java Content Repository specification.

About Midgard2

Midgard2 is an open source content repository library available for multiple programming languages. For PHP it is available as an extension. On many distributions setting this up is as simple as:

$ sudo apt-get install php5-midgard2

The Midgard2 content repository 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:

$article = new net_example_article();
$article->title = "Hello, world";
$article->create();
echo "Article {$article->title} was stored with GUID {$article->guid}";

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 will be needed.

  • Repository = Midgard config + root node
  • Session = Midgard connection
  • Node = Midgard object
  • Property = Property or Parameter of Midgard object
  • Workspace = Midgard root node or workspace

Making the Midgard tree single-rooted

While both Midgard2 and JCR build on the tree concept, the tree in Midgard is multi-rooted. We work around this by making each rootlevel object its own repository.

When user connects to a Midgard2 PHPCR repository, the connection will use configuration to map itself to a particular rootlevel object. A new PHPCR Session will be returned.

Workspaces

When Midgard2's own Workspaces implementation lands in 10.05.5, we will support using JCR Workspaces as well. The workspace strings will be in format:

  • workspace
  • workspace/subworkspace

Namespace mappings

The PHPCR API uses namespaces for node types and property names. The regular Midgard2 MgdSchema RDF mappings should be used for this.

Midgard's MgdSchema types (PHPCR Node types) have a fixed set of properties. To implement the full PHPCR model, additional properties should be implemented using Midgard Parameters.

Basically setting value of Node property foo:bar, can mean depending on MgdSchema, either:

$node->bar = $value;

or:

$node->set_parameter('foo', 'bar', $value);

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

The Midgard2 PHPCR provider is in early stages of development. Our initial goal is to implement JCR level 1 compatibility, verified by passing the relevant Jackalope API tests. Once we know the exact approach to take, adding JCR level 2 should be relatively straightforward. The David's Model notes should be useful for prioritizing features.

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

Feel free to watch the repository, make a fork and submit pull requests. Code reviews, testing and bug reports are also very welcome.

About

Midgard2 implementation of PHP Content Repository (PHPCR)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%