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


Related articles

Google Analytics running on an Apple MacBook.

12 SEO top tips for better ranking with Drupal

Calendar 1 Jun 2016 #SEO #Drupal SEO. Search engine optimisation. Where to begin with the elusive task of search engine optimisation, around which an entire industry has formed?

Read the article
The drupal 8 logo on a blue background with some obscured lines of code.

Kickstarting with Drupal 8 themes

Calendar 21 Oct 2015 #Frontend #Tutorial #Drupal #HTML, CSS & Javascript Drupal 8 has many new exciting features, but perhaps the most exciting of all is the new approach to themes. Our developer Alex gives us the lowdown.

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

A sky scene with indecipherable technical information overlaid for effect indicating cloud hosting

3 reasons your choice of website host isn't just an IT issue

Calendar 16 Aug 2022 #Advice #Security & compliance Choosing the web infrastructure that supports your website is of paramount importance. And given that your choice of website host underpins the ability of your business to exist online, it's fair to say you need to make a well-informed decision about your hosting service.

Read the article
A roll of blueprints

Why documentation and processes could stop your website from failing at a critical moment

Calendar 29 Jun 2022 #Advice #Security & compliance Do you have documentation in place so that, when changes to your website are needed, there is a clear process to be followed whether by your in-house developers or your outsourced digital marketing partners?

Read the article
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

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.