What to keep in mind when creating Drupal 8 projects - for developers

01 Oct 2015


Please note the article's publishing date. Some of the information presented below may not be current anymore.


With only a few critical issues left in the Drupal 8 queue and D8 being surprisingly usable, many developers already use it in small projects to play with the technology and to challenge themselves.
I have to admit, I am no exception - the embracement of many PHP technologies and (finally!) the jump to the OOP paradigm makes me want to stop writing right now and code some more.

Which projects qualify for Drupal 8 today?

I would wait a few months before creating bigger D8 projects for my clients. The community has to play some catching up first and port modules, themes and write documentation. On top of that, apart from all the OOP technologies we love, there have been some new drupalisms introduced and not documented yet - this combined with the lack of contributed module solutions makes D8 development much more time consuming for paid projects in comparison to D7.

Small projects however are very doable.

First however, it may be necessary to upgrade the server, as D8 introduces relatively high PHP and SQL requirements. See the official requirements page.

With its translation capabilities, ckeditor and views in core, creating a simple portfolio or blog website with Drupal 8 may be even quicker than using its predecessor. The built in WYSIWYG even lets you upload files directly into it. A feature for which you had to install ocupload in the past.
On a side note, going through the list of modules, you may be negatively surprised by the fact that it is impossible to disable modules - this has been done by design, check out this page. The gray area where a module has its settings saved in the database but is still disabled, is gone.

Drupal 8 module creation

The small number of contributed modules will force you to create your own, even for small changes on the site. I cannot overstate how fulfilling it is to code Drupal modules and at the same time be able to (mostly) follow PHP best practices. The .module file feels almost like a thing from the past left there to accommodate some developers and site builders resisting change. It will include all the hook functions which will hopefully only call Drupal and custom class methods anyway. Those module class files is where the real action takes place!

Variables as means to store quick data have been replaced by the much more sophisticated configuration system. This move brings many advantages including data portability, an actual relation between the module and its data (no more abandoned variables after module deletion) and many more.

Finally Caching has become smart! Cached content is able to invalidate itself depending on several circumstances, including content changes. Setting cache tags for cached module data is very easy and efficient. This system makes the heavy Drupal technology appear fast on an interpreted language like PHP.

Heads up regarding the devel module: it installs fine, however dpm() runs out of memory and leads to a WSOD, regardless of the amount of memory set. The krumo() function (or better yet your debugger) is a working alternative.

Drupal 8 template creation

You will probably find that there is no real choice in templates and that creating a custom theme is a must. Creating sub themes in Drupal is a treat. TWIG for the markup, YAML for the config files, it all fits rather well together.

For most projects you will be creating a sub theme on top of the included 'classy' theme or another contrib base theme. Adding CSS and JS files and combining them to libraries in the .libraries.yml file provides a lot of flexibility more or less deprecating the D7 libraries module.

Overriding a base theme is really simple by adding specifically named templates, including and excluding(!) certain base theme libraries.

The state of Drupal 8 SEO and spam prevention modules

While Drupal 8 comes with a well balanced selection of  core modules, there is a couple of functionalities which will be added on top in most of your projects. These are spam prevention and SEO. Drupal 7 has a ton of modules for these purposes while Drupal 8... not so much.

In terms of spam prevention, for smaller to medium projects, I recommend the dev version of the Honeypot module. See How to use the Drupal 8 honeypot module efficiently. For big projects, captcha seems to be a good choice, however currently it has some major issues.

In terms of SEO, the metatag module is far from functional (do not bother to download the dev version, it is just some test code displaying a phone number field), but this is not tragic, the metatag module's impact on SEO has been declining a lot anyway.

The real problem has been the lack of an xml sitemap generator. Google loves sitemaps, but the Drupal 8 version of the xml sitemap module is broken. This is why I created the Simple XML Sitemap. It is stable and works well with the latest beta RC release. Feel free to read about it here, or download the module directly from the Simple XML Sitemap module page.

Get ready to work around some issues

As mentioned, the documentation is really lacking, but we have to work with what we have. While everyone is focusing on the critical issues, do keep an eye on the other ones as well. From the top of my head I have experienced D8 issues like

  • css caching problems
  • language detection problems
  • self-resetting menu items
  • broken views contextual filters
  • incomplete entityQuery class
  • missing private file system image styles

... many of those still prevail until beta 15, which is supposed to be the second last beta release. I guess the only thing to do is contributing to the issue queues.

All in all though the experience has been rewarding and I strongly encourage everyone to start hacking with Drupal 8. I am looking forward to completing tons of D8 projects soon. I invite you to share your experience in the comment section.

If you would like to port your website to Drupal 8, make sure to get in touch to get info on migration feasibility and techniques and to acquire a quote.

 

Comments

No themes, No documentation, No contrib modules. I am supposed to do all this AND put out a site on time for my client? No thanks.

Thanks for mentioning the "self-resetting menu items", I was WTFing about what's going on on my website :D

Put out a site for your client first, while doing something D8 on the side, like porting your own website. The contribution part should follow automatically. I assume improving D8 is in your interest, as D7 will be increasingly seen as outdated by clients.

"many of those still prevail until beta 15"

Actually Beta 16 is being released today.

Don't let the lack of ready contributed modules be a distraction. Instead, look at it is a motivation and tool. If there's a larger module you must use, then try converting it. It's a great tool to learn all the changes that Drupal 8 has. Also it is a great time to re-evaluate site structures. As an example, I used Panels pretty heavily in client sites throughout the years. The problem is clients rather pay me to make even the most minor changes, than learn how to use panels or even mess with it. That's made me decide to drop Panels from some larger projects, and instead push everything through template functions and files. This makes it a lot simpler to push out changes as I simply can just push them through GIT, plus have the ability to now easily roll back.

Likewise, on some modules that may be broken, especially between beta releases, usually you can fix them yourself quicker than looking for a patch or anything. A lot of times it turns out something changed in the type hinting for method calls, and if you use a decent IDE, it's very simple to find.

There are many ways to create a new project with Drupal 8, same like as it has been doing for years with Drupal 7. However, if you want a Drupal installation prepared to develop a full web application. In my company many web developers and website copywriters are working, and they are also working in Drupal projects.

Drupal 8. is a great update as compare to drupal 7. there are lots of new features that are same as WordPress. developers can easy to develop their custom web design & development. One of my web design Toronto client want to developed their another website in drupal 8.

Recently upgraded to drupal 8 from drupal 7. It is really amazing. Thanks for sharing tips for drupal 8.
Regards, TechJeny

Recently upgraded to Drupal 8 and it's pretty good.

Regards,
Delk - Web Developer Toronto

Hey, it's been a while since Drupal 8 has been introduced, but this is still informative. I work for web design agency TakeOffRoom and we get requests for web maintenance from clients who are still on the old version. Web developers need to know the difference between Drupal 8 and the previous versions since sometimes we are required to do web development work for clients that haven't yet updated to 8.

Add new comment

The content of this field is kept private and will not be shown publicly.

Restricted HTML

  • Allowed HTML tags: <a href hreflang target> <em> <strong> <cite> <blockquote cite> <pre> <ul type> <ol start type> <li> <dl> <dt> <dd> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.

Get a quote in 24 hours

Wether a huge commerce system, or a small business website, we will quote the project within 24h of you pressing the following button: Get quote