Skip to main content
A humourous keynote slide from a DrupalCon. The slide shows a toddler clenching a fist and some wording saying "Time to kick ass with Drupal 8"

Blog Article

Drupal 8 is coming!

Love it? Share it!

Drupal 8 is soon to be released. So I decided to play with it and share my first impressions and findings.

Out of the box it looks very neat and robust. As opposed to its predecessors it comes with a bunch of modules in core. Views, i18n, transliterations, uuid, strongarm, features, breakpoints ckeditor to name a few all made it into core. Good news, less time spent on module installs. On the list of modules page there is also a search box saving you time on finding that one module among a huge list of others.

Overall Drupal 8 has kept its recognisable Drupal visuals and administrative navigation stayed very similar to Drupal 7. Which is a good thing.

If you are a developer then there is a surprise in the box for you. Better coding practices, object oriented approach, re-usability. Here is a short list of my findings and some things to consider.

1. Make sure you have right system requirements

For those of you running CentOS 6 it comes with Apache 2.2 however Drupal 8 requires minimum Apache 2.4. In this case you will need to either upgrade CentOS Apache or switch to Ubuntu 14.04 which comes with Apache 2.4 installed. To operate with Drush  you will need to install version 8 or checkout dev version. Remove whatever default Drush you have or install both versions side by side. Installing via composer seems to be pretty straight forward. Another thing to notice with Drush is that there is no more Drush cache-clear all. Instead there is Drush cache-rebuild (cr). Drush disable module was deprecated in favour of Drush pm-uninstall module.

2. Write your own module

As a developer the first thing to do is of course to write your own module. Modules have a new home. All Drupal's core modules live in core/modules directory and contributed or custom modules make their habitat in modules folder at the root of Drupal install. If you have a multi site installation and want to separate modules per site you can still do it the old way and place your modules in site/default/modules folder. You will notice that usual module.info file has now become module.info.yml and is written in YML language which makes things a bit more standardized. Now hook_menu is done away with and you can now define your paths in module.routing.yml file. Each route now has its own machine name by which it can be referenced. Menu's page callback is defined as 2 route's parameters: _controller and _content. Controller is a class that provides a method that renders themed output of the route. _content is the name of the method within this controller. Route can not only point to a method within controller but can also execute a service. Service is something new to Drupal and is borrowed from Symphony system. Services are further explained below. Though Drupal's hook system is still in place there is a great addition in Drupal 8 and this is the Plug In system. With the plugin mechanism your code can be completely object oriented and as such fully reusable. It pays taking time to learn about plugins and its discoverability. Youtube is a good place to start.

3. Write your own plugin

We all write code to create custom blocks. Well now there is a plugin to do just that. Plugin is just a PHP class that implements already preconfigured Drupal's plugin interface. In case of blocks this would be BlockPluginInterface. There are also ready to use plugin base classes. For blocks this is BlockBase class which in turn implements BlockPluginInterface. This class has all the method necessary to create a block. Go ahead and browse through the class to see what interesting things you can do with blocks out of the box and if it is not enough use the magic of object orientation and extend it by writing your own methods. Try it out and write your own block plugin. See for yourself how simple and straight forward it is. I bet you will get 'hooked'.

4. Dependency injections

As developers we are constantly bombarded by a very technical terminology like 'dependency injection'. Though it sounds very complicated in fact it is very simple and refers to passing an instantiated class as a parameter to another class. So instead of hardcoding class instantiation in a class you can pass it as a parameter or in another words 'inject' it into your main class. Dependency injection gives main class flexibility of processing different types of classes.

5. Services

Services are all about dependency injection. In fact services serve as a wrapper to a class that has specific classes passed to it as parameters. Let's say you have 2 instances of class A. In the first instance it is injected with class B and C and in the second instance it is passed classes D and F. You might be in a situation where you need to instantiate class A with different parameters a few times. Every time you want to do this you would need to repeat instantiation of the injected classes. With services it becomes much easier. Service is a name defined by you that points to the combination of the main and injectable classes. Every time you call a service by its name it will instantiate and inject correct classes into the main one for you. So in our example calling on service 'abc' would return an instance of an A class with B and C injected into it. In turn calling on service 'adf' would return an instance of an A class with injected D and F instances. Services can be defined in module.service.yml file where you define service name, main class the service points to and an array of arguments containing classes that should be injected into the main class. 

Of course there are many more things than this in Drupal 8

Mastering them takes time and practice and this is what makes development exciting. The best way to learn Drupal 8 is to help with resolving a huge list of issues on Drupal.org. Check it out, read comments, have a look at submitted patches and eventually write your own. After all this is what open source is all about.

Way to go Drupal 8.

Alex Benjamin - Drupal Developer

Written by

Alex Benjamin

Drupal Developer

Love it? Share it!

More from our blog

If you enjoyed this why not check out more articles from our blog?

Feb
14
2019
Client Advice
Wooden board game letters organised to make the word 'Cost'

6 ways to manage the biggest cost influencing factors of a website project

Understandably it’s a very common question. However, here’s why there’s no simple answer, and how you can influence the bottom line.
Read the article
Barry Fisher - Director

Written by

Barry Fisher

Technical Director
Oct
2
2018
Client Advice
A clock and some coin piles sprouting vegetation - a metaphor for return on investment over time

ROI Focused Websites: 8 questions you should ask before engaging a web design agency

The first article in our Return on Investment (ROI) series asks 8 important questions that will determine your success.
Read the article
Barry Fisher - Director

Written by

Barry Fisher

Technical Director
Sep
11
2018
Client Advice
Drupal Tech
A boy looking very confused and scratching his head

What is Pattern Lab and why should I care about it?

Our front-end developer discusses why you and your business should be considering Pattern Lab for your next Drupal project.
Read the article
Darren Fisher - Designer & Frontend Dev

Written by

Darren Fisher

Designer & Frontend Dev
Aug
22
2018
Drupal Tech
Technology
Atomic design components from atoms, through molecules, organisms, templates, pages to Drupal.

10 lessons we learned from our first Drupal 8 + Pattern Lab via Emulsify project

The musings of our front end developer after the launch of our first Pattern Lab + Drupal 8 project via the Emulsify base theme.
Read the article
Darren Fisher - Designer & Frontend Dev

Written by

Darren Fisher

Designer & Frontend Dev
Nov
22
2017
News
Left to right: Barry Fisher, Stephen Brownlie, Darren Fisher

A new space to create and innovate

We are excited to announce that we are the first business to move in to the brand new BASE Bordon innovation centre.
Read the article
Barry Fisher - Director

Written by

Barry Fisher

Technical Director
Oct
4
2017
News
An aerial view of the Danube through Vienna at dusk.

We went to DrupalCon 2017 in Vienna

This year's European Drupal conference took place in Vienna, Austria ahead of the news that there will be no DrupalCon Europe 2018.
Read the article
Darren Fisher - Designer & Frontend Dev

Written by

Darren Fisher

Designer & Frontend Dev