Forest header image

Symfony Finland
Random things on PHP, Symfony and web development

What eZ Platform adds to Symfony

eZ Platform is a Content Management System built with the Symfony Full Stack framework. While this may be clear to developers who have worked with it; it maybe somewhat vague for the unitiated. Especially when compared with Concrete5 or Drupal, which have adopted Symfony components into their core.

The Symfony Full Stack Framework is a HVMC framework built using the Symfony Components. As opposed to popular minimalistic frameworks such as Code Igniter or Express.js from the Node.js realm, the Symfony Framework offers quite a bit of functionality out of the box.

Infact Symfony does not dictate any "M" in the HMVC structure, but there are plenty of storage models a Symfony framework application can have. In the case of eZ Platform, the default data model just happens to be the eZ Platform content repository.

The relationship between Symfony and eZ Platform is very similar to Expression Engine using Code Igniter or EPiServer using ASP.NET MVC.

What does Symfony bring to the table...

eZ Platform is an application built on the Symfony Framework and as such can enjoy base services and functionalities provided by the framework, some of which are listed below.

Request-Response concept

While often many articles (including this one) introduce Symfony as a HVMC framework, it is considered as a HTTP framework by the lead developer. The core function of Symfony is to receive HTTP requests and send some form HTTP responses.

Most of the time responses are HTML, but if you return a JsonResponse then the framework will interpret is as JSON and send the appropriate headers and serialize the payload to JSON format.

Structure and best practises

The Symfony Framework introduces a uniform application structure. All applications follow the same directory structure and methods for loading classes, session and security features, debugging tools and other rudimentary functionalities one might expect from a framework.

Extensibility definition

The bundle system defines a structure that allows you to build reusable packages that can be shared between different application built with the framework. This is similar to Drupal Modules or WordPress Plugins and can include everything from templates to security voters attaching to the access control system.

Internationalization framework

Symfony comes with a comprehensive support for internationalization (i18n). All requests have a locale which in turn can be used to translate text snippets in the application templates or PHP code. There are also auxiliary scripts for generating translations from bundles and tools for debugging translations.

Forms

Forms are at the heart of most web applications. They're generally not the sexiest things to work with, but Symfony comes with a comprehensive and flexible framework for managing form generation and action handling.

Twig templating

The Symfony Framework has open APIs to integrate various templating systems, such as HAML using an integration bundle. By default it ships with support for Twig, a popular PHP templating system very much like the Jinja2 templating from the Python world. Twig is becoming a staple among PHP developers.

... and what does eZ Platform add on top?

eZ Platform takes Symfony and adds another layer of functionalities for developers to work with.

Content Repository

The most important addition is the content repository. It provides developers with a flexible content storage with rich metadata and a media library and an integrated Solr powered search. The Public API allow developers to interact with the repository in their Symfony code anywhere in the application, including responding to Signals sent by the repository.

REST API

In addition to the PHP API exposed internally, eZ Platform also comes with a REST API which allows external applications to interact with the content repository using HTTP. The REST API is extensible and can use other data sources, such as Graph Databases, from your Symfony backend.

Dynamic routing

eZ Platform uses the Symfony CMF Routing Component to enhance the routing function (matching an URL to a resource). It enables dynamic routing based on the content repository, where as by default Symfony routes need to be defined.

Thanks to the chained router, routes can be set to attach to the request before eZ Platform does, so mixing dynamic and static routes is straightforward.

Siteaccesses

eZ Platform adds the concept of sites (or siteaccesses) to Symfony. A siteaccess is a set of configuration values defining the used content repository, the language(s) and other settings. Individual siteaccesses are then mapped to be visible in a certain URL, such as:

  • http://example.de/
  • http://example.com/de/
  • http://de.example.com/

The configuration can match the URL, the domain or any combination of these. The site can also dynamically load specific configurations and they are transparently mapped to static routes as well, so a static custom controller would match any of these URLs:

  • http://example.com/hello/John
  • http://example.com/ger/hello/John
  • http://ger.example.com/hello/John

User interface

As a server framework Symfony does not define any user interface. There are a number of options available, but none of them is definitive enough to give Symfony a familiar feel to all users of "Symfony".

eZ Platform comes with an administration user interface. It uses the REST API for interacting with the repository and can be extended with other CRUDs to provide a consistent user experience for viewing and manipulating various data sources.

User and permission management

eZ Platform integrates closely with the Symfony session system and shares the sessions. Together with the role based permission model it is straightforward to grant rights granularly to individual functions of the content repository, and within the application in general.

Conclusion

In addition to these, there are numerous other features within both Symfony and eZ Platform. It's also worth noting that there are third party Symfony bundles being used for key functionalities of eZ Platform such as:

eZ Platform is just one of many applications that have chosen to offload a number ofs functions to a general purpose framework, such as Symfony. Other notable projects using the Symfony Framework are ORO CRM, Prestashop and Sylius.

The ideal way of starting to use eZ Platform is to learn Symfony first. If you jump straight into eZ Platform the experience might be overwhelming, so it's easier to start small and then move your way up to eZ Platform.

The advantage for any application that adopts a general purpose framework such as Symfony, ASP.NET MVC or Hapi.js is that it is a broader investment. Rather than learning proprietary directory structures, form implementations and so on, you've got skills that are applicable in more places.

Hell, you might start with eZ Platform and behind the scenes move your content repository over to PHPCR in the future.


Written by Jani Tarvainen on Thursday February 11, 2016
Permalink - Tags: symfony, ezplatform, php

« Symfony and the Google App Engine - What's on the Menu, Symfony? »