Infrastructure Options for Hosting Multiple Drupal Sites

A project I was recently working on had in place a cloud-based infrastructure that was designed to support a single installation of the Drupal CMS running in Amazon Web Services (AWS). This infrastructure included an auto-scaling setup with load balancers hosting a ‘cache’ layer and an ‘application’ layer that hosted the Drupal CMS. On the backend tier, an AWS Relational Database Service (RDS) provided the MySQL database needed for the application. There were other components of the infrastructure such as our shared services for continuous integration, monitoring and development tools. ...

March 31, 2018 · 6 min · 1262 words · icarnaghan

Lessons Learned using Drupal’s Domain Access Module

Over the last few months my team has been developing microsites to accompany our main website. The requirements for these sites included having their own domain, theme and separate content. After reviewing options in Drupal 7, I decided the best approach given our situation was to use the Domain Access Module. The Domain Access Module provides a very solid and powerful framework for developing additional sites within your existing Drupal CMS, but it can also be somewhat complicated to setup for any given use case. I have documented some of the lessons learned over the last few months as we implemented Domain Access in our own project. ...

October 3, 2017 · 6 min · 1135 words · icarnaghan

Preparing for the Acquia Certified Developer Exam Drupal 8

The Acquia Certified Developer exam Drupal 8 just launched a couple of months ago. I was interested in studying for this exam as I have been working in Drupal 8 for the last six months and future projects look most likely to be Drupal 8 based. I had looked at the various Acquia certification tracks in the past, however I was never fully committed to the Drupal 7 track so I was happy when Acquia announced first the Foundations and then later the Certified Developer exams. I took the Foundations exam first and found that while I was weaker in my front-end Drupal 8 skills, I managed to pass. Later when I sat for the Certified Developer exam I realized there was a bit of cross over in terms of the questions, in fact I think a few of them were taken directly from the foundations exam. I would recommend anyone considering the Certified Developer exam to first take Foundations as it will give you a good idea of the type of questions to expect. ...

September 1, 2016 · 4 min · 768 words · icarnaghan

Dependency Injection / Service Container Example

In an earlier post, I outlined the basics of dependency injection and talked a little bit about the Drupal 8 service container and how we can use this in our code. Day 16 of Drupal Activity Cards provides a task for us to implement dependency injection in one of the Drupal 8 Example modules. The examples module is a great resource for developers getting started in Drupal coding. The modules included gives us basic functionality that provides easy to follow starting points for a number of different needs. For our dependency injection example we are going to look at page_example, a simple module for generating a Drupal 8 page via a controller. A function called simple() returns a basic page. We are going to extend this function to provide a log entry every time a use visits this page. ...

August 22, 2016 · 3 min · 573 words · icarnaghan

Logging in Drupal 8

Logging is very important in any production site because we don’t have the same ability to debug code that we have in our development environments. Drupal 7 had a very robust logging system called watchdog(), which has been replaced by logger in Drupal 8. This post summarizes a basic use case for logging in Drupal 8 continuing the Drupal 8 Activity Cards series on Day 13. Amber Matz breaks down logging in Drupal 8 concisely in How to Log Messages in Drupal 8. In her article, she breaks down the code needed to implement logger and provides solid explanations. The examples provided involve procedural coding in the .module file as does the example I provide in this article. If you are writing controllers or forms that extend ControllerBase or FormBase then it would be better to use the service container to inject logger into your code. ...

August 19, 2016 · 2 min · 384 words · icarnaghan

Introduction to Drupal 8 Theming

Drupal 8 has a new theme engine, however many of the concepts we are familiar with in Drupal 7 are still in place in this new version. Themes still have the same ability to overwrite various templates within core, only now instead of modifying .tpl.php files, you will be creating Twig files in their place. Theme functions are still available to use, however they are now kept in the .theme file instead of template.php. Other changes worthy of exploring in more depth are briefly summarized below. ...

August 18, 2016 · 4 min · 660 words · icarnaghan

Creating a Custom Content Entity Type

Drupal 8 has seen a lot of improvements for content entities and with the new Drupal console, setting up a content entity has been made a lot easier with the addition of boilerplate code generation. Day 11 of the Drupal 8 Activity Card set focuses on content entities, how they can be setup in Drupal 8, how we might add our own custom fields to the boilerplate code provided, and how this is managed within the Drupal 8 administration system. ...

August 17, 2016 · 6 min · 1080 words · icarnaghan

Configuring your Local Drupal 8 Development Environment

I have struggled with properly optimizing my local environment in terms of enabling debugging and disabling cache for a while. There isn’t that many steps you need to cover in order to have a proper working development environment. After reviewing Day 10 I completed setting up my environment the correct way and have outlined this in the following sections. Step 1 Enable settings.local.php Copy and Rename /sites/settings.example.local.php -> /sites/default/settings.local.php Uncomment the following lines in your settings.php file: # if (file_exists(__DIR__ . '/settings.local.php')) { # include __DIR__ . '/settings.local.php'; # } Step 2 Disable Cache Services In your sites/default/settings.local.php file, uncomment the following: # $settings['cache']['bins']['render'] = 'cache.backend.null'; Rebuild your site configuration by visiting yoursite.local/rebuild.php Step 3 Disable Twig Cache and Enable Debugging Add the following lines to your /sites/development-services.yml (Refer to /sites/default/default-services.yml for all options) parameters: twig.config: debug: true auto_reload: true cache: false Clear Cache and then verify Twig debugging has been enabled by refreshing your Drupal 8 homepage. Review your source code and you should see something similar to: <!-- THEME DEBUG -->; <!-- THEME HOOK: 'html' -->; <!-- FILE NAME SUGGESTIONS: * html--front.html.twig * html--.html.twig x html.html.twig -->; Twig debugging gives a lot of helpful information scattered throughout your source code in the form of comments. ...

August 16, 2016 · 1 min · 207 words · icarnaghan

Attaching JS and CSS Assets in Drupal 8

Drupal 8 has introduced a different way of attaching JavaScript and CSS to themes and custom modules via a new concept called libraries, which are covered in Day 9. Libraries are essentially .yml files that define different groups of assets that can later be attached via module code. When I started working with the theme layer in Drupal 8, I quickly realized that certain things are very different from Drupal 7. One of the main gotchas for anyone new to Drupal 8 is the idea that JavaScript libraries are now only loaded where they are needed. In contrast to Drupal 7 where jQuery for example, was loaded on every page, in Drupal 8 jQuery is no longer automatically loaded. This provides for a better optimized site with only the required libraries included in areas that they are needed. ...

August 15, 2016 · 3 min · 491 words · icarnaghan

Drupal 8 Plugin System

There is a lot of new terminology in Drupal 8 and for anyone not familiar with Object Oriented programming, some of it can be downright confusing. For myself, I have worked with OOP for quite a while, however I have not spent as much time writing custom modules for Drupal 7. While I am familiar on the surface with the hook system and API at a very novice level, I have never really had to do any intense back end development in D7. Now that I am working in Drupal 8, things are quite different with my projects at work. Thankfully my OOP background has filled in some of the gaps, however my lack of Drupal 7 module development knowledge has proven to be a burden. ...

August 14, 2016 · 3 min · 542 words · icarnaghan