Best Practice Site Architecture in Drupal 8

Post on 07-Apr-2017

144 views 0 download

Transcript of Best Practice Site Architecture in Drupal 8

Best Practice Site Architecture in D8

Pantheon.io 2

Who Are We?

Mark Ferree

Director of Engineering

Matt Cheney

Product & Co-Founder

The Dawning of the Age of Drupal 8

168,553 sites are using Drupal 8!https://www.drupal.org/project/usage/drupal

Chapter Three has done a lot of Drupal 8 projects for a number of different clients.https://www.chapterthree.com/drupal8

Pantheon has been hosting Drupal 8 for 3+ years across 20,000+ sites!https://pantheon.io/drupal-8

3

Drupal 8: On It’s Own Terms

Drupal 8 is ready for production (and has been so for awhile)

There isn’t always “a module for that” (but the architecture makes that OK)

“Content Management Features” are A+(this makes site architecture much easier)

4

As a developer:

I never want to use Drush Make again

5

Composer for Patch Management

https://github.com/cweagans/composer-patches.git

"patches_applied": {

"remote video URLs": "https://www.drupal.org/files/issues/2728241-2.patch",

"default ref ID from logic to base fields": "https://www.drupal.org/files/issues/2731915-4.patch",

"IEF form handler": "https://www.drupal.org/files/issues/2743289-2.patch",

"Add a field formatter for the player": "https://www.drupal.org/files/issues/2803173-8.patch",

"Add AMP video player integration": "https://www.drupal.org/files/issues/2817233-4.patch"

}

As a Site Owner:

I want to ensure nobody can change configuration on production.

7

Config Read Only

https://www.drupal.org/project/config_readonly

To enable read only mode, enable this module and add this to your settings.php:$settings['config_readonly'] = TRUE;

As a Developer:

I want to have better test coverage for my Drupal code.

9

Testing Improvements

public function testSessionExpiration() {

$this->drupalGet('<front>');

$session_assert = $this->assertSession();

$page = $this->getSession()->getPage();

for ($i = 0; $i < 25; $i++) {

$page->clickLink('Link to front page');

$session_assert->statusCodeEquals(200);

}

}

}

As a Themer:

I want to hide the sidebar... but only on a few pages.

12

Twig Blocks

“Blocks are used for inheritance and act as placeholders and replacements at the same time.”- http://twig.sensiolabs.org/doc/2.x/tags/block.html

13

Twig Blocks{#

/**

* @file

* Theme override to display a 404 page.

....

*/

#}

{% extends 'page.html.twig' %}

{% block sidebar_first %} {% endblock %}

Twig Blocks

{% block sidebar_first_wrapper %} {% if page.sidebar_first %}

<aside class="column-sidebar sidebar" role="complementary">

<div class="container">

{% block sidebar_first %}

{{ page.sidebar_first }}

{% endblock %} {# /sidebar_first #}

</div> <!--/.column-sidebar-container -->

</aside> <!--/.column-sidebar -->

{% endif %}

{% endblock %} {# /sidebar_first_wrapper #}

15

Pantheon.io

Tips for Making Your Architecture Pleasurable

Pantheon.io

Dealing with the Drupal 8 Contrib Space

Pantheon.io

Best Practices for Debugging in D8

Credit: https://blog.liip.ch/archive/2016/06/20/lets-debug-drupal-8.html

Pantheon.io

Best Practices for Debugging in D8

Credit: https://knpuniversity.com/screencast/drupal8-under-the-hood/debugging

Pantheon.io

Best Practices for Debugging in D8

Credit: https://blog.liip.ch/archive/2016/06/20/lets-debug-drupal-8.html

Pantheon.io

Best Practices for Debugging in D8

Credit: https://chrome.google.com/webstore/detail/drupal-template-helper/ppiceaegogijpjodfpiimifhbnaifbnn

Pantheon.io

Best Practices for Debugging in D8

Credit: https://drupalize.me/blog/201405/lets-debug-twig-drupal-8

Pantheon.io

Best Practices for Debugging in D8

Credit: https://blog.liip.ch/archive/2016/06/20/lets-debug-drupal-8.html

Pantheon.io

Architecting the Admin

Pantheon.io

Page Layout as Architecture

25

Pantheon.io

How Do You Build It in Drupal 8?

Pantheon.io

How Do You Build in Drupal 8?

Pantheon.io

How Do You Build in Drupal 8?

Pantheon.io

Awesome Workflows in Drupal 8

Pantheon.io

How Do You Build in Drupal 8?

Pantheon.io

How Do You Build in Drupal 8?

Pantheon.io

How Do You Build in Drupal 8?

Pantheon.io

Making an Architectural Plan

33

Questions & Discussion

How is Drupal 8 Going for You?What is Easy? What is Difficult?

Thank you