14.06.2013 Views

The Symfony CMF Book

The Symfony CMF Book

The Symfony CMF Book

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

RDBMS<br />

Looking at the above requirements it becomes apparent that out the box an RDBMS is ill-suited to<br />

address the needs of a CMS. RDBMS were never intended to store tree structures of unstructured content.<br />

Really the only requirement RDBMS cover from the above list is the ability to store content, some way<br />

to reference content, keep multiple separate content structures and a basic level of access controls and<br />

triggers.<br />

This is not a failing of RDBMS in the sense that they were simply designed for a different use case: the<br />

ability to store, manipulate and aggregate structured data. This makes them ideal for storing inventory<br />

and orders.<br />

That is not to say that it is impossible to build a system on top of an RDBMS that addresses more or<br />

even all of the above topics. Some RDBMS natively support recursive queries, which can be useful for<br />

retrieving tree structures. Even if such native support is missing, there are algorithms like materialized<br />

path and nested sets that can enable efficient storage and retrieval of tree structures for different use cases.<br />

<strong>The</strong> point is however that these all require algorithms and code on top of an RDBMS which also tightly<br />

bind your business logic to a particular RDBMS and/or algorithm even if some of them can be abstracted.<br />

So again using an ORM one could create a pluggable system for managing tree structures with different<br />

algorithms which prevent binding the business logic of the CMS to a particular algorithm.<br />

However it should be said once more, that all Bundles and Components in the <strong>CMF</strong> are developed<br />

to enable any persistent storage API and we welcome contributions for adding implementations for<br />

other storage systems. So for example <strong>CMF</strong> RoutingBundle currently only provides Document classes for<br />

PHPCR ODM, but the interfaces defined in the Routing component are storage agnostic and we would<br />

accept a contribution to add Doctrine ORM support.<br />

PHPCR<br />

PHPCR 3 essentially is a set of interfaces addressing most of the requirements from the above list. This<br />

means that PHPCR is totally storage agnostic in the sense that it is possible to really put any persistence<br />

solution behind PHPCR. So in the same way as an ORM can support different tree storage algorithms<br />

via some plugin, PHPCR aims to provide an API for the entire breath of CMS needs, therefore cleanly<br />

separating the entire business logic of your CMS from the persistence choice. As a matter of fact the only<br />

feature above not natively supported by PHPCR is support for translations.<br />

Thanks to the availability of several PHPCR implementations supporting various kinds of persistence<br />

choices, creating a CMS on top of PHPCR means that end users are enabled to pick and choose what<br />

works best for them, their available resources, their expertise and their scalability requirements.<br />

So for the simplest use cases there is for example a Doctrine DBAL based solution provided by the<br />

Jackalope 4 PHPCR implementation that can use the SQLite RDBMS shipped with PHP itself. At the other<br />

end of the spectrum Jackalope also supports Jackrabbit 5 which supports clustering and can efficiently<br />

handle data into the hundreds of gigabytes. By default Jackrabbit simply uses the file system for<br />

persistence, but it can also use an RDBMS. However future versions will support MongoDB and support<br />

for other NoSQL solutions like CouchDB or Cassandra is entirely possible. Again, switching the<br />

persistence solution would require no code changes as the business logic is only bound to the PHPCR<br />

interfaces.<br />

Please see installing-configuring-doctrine-phpcr-odm for more details on the available PHPCR<br />

implementations and their requirements and how to setup <strong>Symfony</strong>2 with one of them.<br />

3. http://phpcr.github.com<br />

4. https://github.com/jackalope/jackalope<br />

5. http://jackrabbit.apache.org<br />

PDF brought to you by<br />

generated on June 13, 2013<br />

Chapter 6: Choosing a Storage Layer | 26

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!