DZone
Web Dev Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Web Dev Zone > Midgard2 PHPCR provider hits 1.0

Midgard2 PHPCR provider hits 1.0

Henri Bergius user avatar by
Henri Bergius
·
Dec. 24, 11 · Web Dev Zone · Interview
Like (0)
Save
Tweet
3.11K Views

Join the DZone community and get the full member experience.

Join For Free

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:

  • More traditional object access with getters and setters to the repository
  • Multilingual content storage

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.

 

Source: http://bergie.iki.fi/blog/midgard2_phpcr_provider_hits_1-0/

 

Database optimization PHP Repository (version control) Property (programming) Apache Jackrabbit Object model Type system Content repository CI/CD

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Vaadin Apps as Native Executables Using Quarkus Native
  • Is Your Code DRY or WET?
  • Writing Beautiful, Optimized, and Better .NET Code With NDepend Static Analysis
  • Is DataOps the Future of the Modern Data Stack?

Comments

Web Dev Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo