In June 2019 I started working as a back-end Developer on Drupal 8, an Open Source CMS still new to me, seven months later I wanted to write my impressions.
Before that moment I had already worked with Open Source CMS, such as WordPress or PrestaShop, but Drupal was an almost new world for me, I had used it almost 6 years ago, for inserting content and I didn’t like it.
In June, when they proposed it to me, I was initially scared, but fortunately I had pleasant surprises.
A particular version: Drupal 8
Drupal, which has always defined itself as a CMF and not a CMS, has introduced the Symfony 3.2 Framework in the core since version 8. Symfony for me is an already known Framework, in 2015 I had already worked with this technology, even if in version 1.4, remaining particularly satisfied.
Let’s start with the fundamentals
Before I got my hands on the code, I started with the theory. So I looked for some online courses and some books.
Among the online courses I opted for drupalize.
Instead among the books I opted for:
And after the first tests after the download of Drupal.
The data structure
Once we got the specifications of the first points of the project we started to study the data structure. A very convenient thing about Drupal is that directly from the CMS you can create your own Custom Types and related fields.
So we can, directly from CMS, create new entities or modify existing ones. For example if we wanted to add the “profession” field in a user, a native entity in Drupal, we can do it directly from our control panel.
Also from the control panel we can create individual instances of the entity, which in Drupal are called “Nodes”.
The same logic also applies to taxonomies, if we wanted to add categories or tags, including their dictionary, for example, we can easily do it from the control panel.
The Drupal 8 cache
On the database side, we find a table for each field we have created. If we wanted to use a node, with all its fields, our CMS will find itself in front of a Query composed of as many joins as the fields. If we think about pages where we work on nodes of multiple entities, the queries are very heavy.
For this problem the Drupal cache helps us, which in addition to working on the view also works on our entities.
The Drupal 8 cache was a huge surprise and I believe that soon I will dedicate a blog post just for you.
Thanks to this, we can drastically reduce development times on the “Model” side and therefore be able to devote more time to the development of the Controller.
After creating our data structure, it is time to create our functions.
To create new features, I mainly work with creating modules. Inside the modules I can create routing rules that lead to my controllers or my forms or hook up to the many hooks that Drupal offers me.
Controller and Form
Given the yml structure and the controllers I resented the Symfony climate. Using a file I create the routing rule in which I can set:
- url address;
- The controller or form to be called;
- if the passage of variables is expected in Post or Get;
- access rules;
- if the target has cache enabled.
The Hooks are very similar to those of WordPress or PrestaShop. These are functions that are called when a certain event starts.
Some of the most frequent hooks are:
- saving a node;
- when loading a node;
- when loading a page;
- to the Submit of a form;
- creating / updating / deleting a user.
All this allows me to create a structure to pass to the Front End Developer.
Drupal 8 VS other CMS
Without a doubt Drupal, and especially Drupal 8, is a very convenient CMS / Framework for a developer.
I spoke at the WordCamp in Milan I also talked about this, showing the differences between the development method on Drupal 8 and WordPress.
I have a newsletter where you can follow me: Subscribe to the newsletter!
Coffee / beer break
A programmer is a creature that converts coffee / beer into code.
If you want other articles like this you can contribute:
Offer me a coffee
Offer me a beer