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'

Drupal 8 is coming and we're getting ready!

16 Sep 2015

Alex Benjamin - Drupal Developer

Written by
Alex Benjamin
Drupal Developer

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.

Darren Fisher - Designer & Developer

Get in touch about your project

Give us a call or send us an email to talk through your project

telephone+44 (0) 203 743 0886

emaildarren.fisher@pivale.co

Related articles

The Convention Centre Dublin (CCD) - a large glass cylindrical building situated on Dublin's River Liffey.

We went to DrupalCon 2016 in Dublin

Calendar 3 Oct 2016 #Press #Drupal Once again this year we had the ultimate pleasure of being guests in another exciting European city as we attending the first ever Drupal conference in Dublin.

Read the article
Real Life Digital merchandise stand at DrupalCamp London 2017.

We went to DrupalCamp London 2017

Calendar 6 Mar 2017 #Press #Drupal DrupalCamp London celebrated its fifth birthday this year, and for the first time Real Life Digital were official sponsors of the CxO day.

Read the article
A sign post with writing Which Way To Go in opposite directions with the WordPress logo on the left and the Drupal logo on the right.

WordPress vs Drupal

Calendar 12 Jul 2021 #Insights #Advice #Drupal #WordPress Explore the differences and pros/cons of both WordPress and Drupal.

Read the article

More recent articles

An ambiguous figure in a suit throwing dice towards he camera.

Are you gambling with the security of your business?

Calendar 7 Jun 2022 #Security & compliance Ignoring security updates will seriously impact your business. It's time to take action.

Read the article
A series of tesselating hexagons containing padlocks - one of which is open and highlighted in red.

Why poor web security will damage your business

Calendar 27 Apr 2022 #Security & compliance The consequences of poor web security can be catastrophic so it's essential you have a strategy.

Read the article
A large padlock integrated in to a circuit board.

Five reasons why you need ongoing website maintenance

Calendar 10 Mar 2022 #Security & compliance Ongoing security maintenance is essential to the longevity of your website or application.

Read the article

Subscribe for email updates

1 Your details

2 Your interests

Please select which Pivale services are of interest to you:

3 Legal info

By subscribing, you acknowledge that your information will be transferred to our marketing platform for processing.

You can unsubscribe at any time by clicking the link in the footer of our emails. You can find out more in our privacy policy.