Development News

The Accidental Coder: 8: Adding an admin page with a config settings form to a custom module

Main Drupal Feed - Tue, 01/01/2019 - 02:19
8: Adding an admin page with a config settings form to a custom module ayen Mon, 12/31/2018 - 21:19

Wim Leers: A dozen years of Drupal

Main Drupal Feed - Mon, 12/31/2018 - 22:13

Last week was my twelfth Drupalversary!

The first half dozen years as a volunteer contributor/student, the second half as a full-time contributor/Acquia employee. Which makes this a special Drupalversary and worth looking back on :)


The d.o highlights of the first six years were my Hierarchical Select and CDN modules. I started those in my first year or so of using Drupal (which coincides with my first year at university). They led to a summer job for Mollom, working with/for Dries remotely — vastly better than counting sandwiches or waiting tables!

It also resulted in me freelancing during the school holidays: the Hierarchical Select module gained many features thanks to agencies not just requesting but also sponsoring them. I couldn’t believe that companies thousands of kilometers away would trust a 21-year old to write code for them!

Then I did my bachelor thesis and master thesis on Drupal + WPO (Web Performance Optimization) + data mining. To my own amazement, my bachelor thesis (while now irrelevant) led to freelancing for the White House and an internship with Facebook.

Biggest lesson learned: opportunities are hiding in unexpected places! (But opportunities are more within reach to those who are privileged. I had the privilege to do university studies, to spend my free time contributing to an open source project, and to propose thesis subjects.)


The second half was made possible by all of the above and sheer luck.

When I was first looking for a job in early 2012, Acquia had a remote hiring freeze. It got lifted a few months later. Because I’d worked remotely with Dries before (at Mollom), I was given the opportunity to work fully remotely from day one. (This would turn out to be very valuable: since then I’ve moved three times!) Angie and Moshe thought I was a capable candidate, I think largely based on the Hierarchical Select module.
Imagine that the remote hiring freeze had not gotten lifted or I’d written a different module? I was lucky in past choices and timing.
So I joined Acquia and started working on Drupal core full-time! I was originally hired to work on the authoring experience, specifically in-place editing.
The team of four I joined in 2012 has quadrupled since then and has always been an amazing group of people — a reflection of the people in the Drupal community at large!

Getting Drupal 8 shipped was hard on everyone in the community, but definitely also on our team. We all did whatever was most important; I probably contributed to more than a dozen subsystems along the way. The Drupal 8 achievement I’m most proud of is probably the intersection of cacheability and the render pipeline: Dynamic Page Cache & BigPipe, both of which have accelerated many billions responses by now. After Drupal 8 shipped, my primary focus has been the API-First Initiative. It’s satisfying to see Drupal 8 do well.

Biggest lessons learned:

  1. code criticism is not personal criticism — not feeling the need to defend every piece of code you’ve written is not only liberating, it also makes you immensely more productive!
  2. always think about future maintainability — having to provide support and backwards compatibility made me truly understand the consequences of mistakes I’ve made.

To many more years with the Drupal community!

Jeff Geerling's Blog: Make composer operations with Drupal way faster and easier on RAM

Main Drupal Feed - Mon, 12/31/2018 - 15:42

tl;dr: Run composer require zaporylie/composer-drupal-optimizations:^1.0 in your Drupal codebase to halve Composer's RAM usage and make operations like require and update 3-4x faster.

A few weeks ago, I noticed Drupal VM's PHP 5.6 automated test suite started failing on the step that runs composer require drupal/drush. (PSA: PHP 5.6 is officially dead. Don't use it anymore. If you're still using it, upgrade to a supported version ASAP!). This was the error message I was getting from Travis CI:

PHP Fatal error:  Allowed memory size of 2147483648 bytes exhausted (tried to allocate 32 bytes) in phar:///usr/bin/composer/src/Composer/DependencyResolver/RuleWatchNode.php on line 40

I ran the test suite locally, and didn't have the same issue (locally I have PHP's CLI memory limit set to -1 so it never runs out of RAM unless I do insane-crazy things.

AddWeb Solution: 2018 - A ‘Year’ full of Smiles, Stronger Bonds & Success!

Main Drupal Feed - Mon, 12/31/2018 - 12:03

Past is a place, thoroughly familiar and yet the experience of revisiting it varies drastically. Revisiting some leaves you with happy nostalgia, some with innocent laughter, some with a moment of pride, and some, a prick of sadness or regret. But yet we choose to visit this place called ‘past’ through our memory, time and again. In fact, we recently did so by revisiting the year 2018, like many others, that is about to end in just a handful of hours. And fortunately, it was filled with a host of happy moments to rejoice and relish, topped by several breakthrough changes and chances we’ve embraced with all love & warmth.

The year 2018 has been the most eventful year for the AddWeb-traveling, counting right from the moment of moving into altogether new office space to officially being a supporting partner of and everything in between. It’s a journey no less than a cinematic experience, with all the drama, emotions and heroic ending - full of catharsis. Let us take you through this marvelous journey, as experienced by AddWeb-ians.


Welcoming 2018 - The Journey Begins, Quite Literally!

, ,

The hobby of traveling might be a trending one today. But we refrain from polluting our passion for traveling, by putting it under the category of ‘trending’. We’re so much about traveling that it has become just a part of our existence, now. Apart from all the traveling we individually do, throughout the year, we also make sure to plan at least one with our AddWeb family. And this time, we literally began our journey of 2018 by going on a trip to Jaisalmer - amidst sand dunes and folk tunes, starry nights and tipsy sites; quite literally!  


AddWeb Family Celebrate Emotions!

, ,

We promised you a journey with emotions at the backdrop. So, here we share a set of different emotions we shared and celebrated across the year.

  • Celebrating the born-day of our dear AddWebians with cakes, candles, and compassion

  • Celebrating the unity in diversity of the Republic of India with the strength of tri-color dress code and decorations

  • Celebrating the diverseness of our being with colors during the festival of Holi

  • Celebrating the feminine force on Women’s day by showing them the feeling of gratitude with ‘sweet’ presents

  • Celebrating the feeling of freedom on Independence day by painting our mood with patriotism

  • Celebrating the oneness of AddWeb family with an electrifying and energetic party - The AddWeb Annual Event at Olives Restaurant

  • Celebrating the almighty of auspiciousness - the cherubic Ganesha with an immense amount of faith and festive decorations on the occasion of Ganesh Chaturthi

  • Celebrating the festive mood of Diwali with DIY decorations, dazzling traditional dresses, delicious Diwali lunch, and gifts!

  • Celebrating the Christian festival of Christmas with a dress code, gifts, and our own two self-proclaimed Santas!

Level up, Metaphorically & Literally!

, ,

Well, it wouldn’t be an exaggeration if we said we literally levelled-up this year. Because this very year we moved into a new & bigger office space that is a few floors up from the old one. And we guess, this clearly states that we grew bigger in terms of our employee strength too, or as we like to address it - our AddWeb family grew even bigger! Yes, we started off from 50+ in January 2018 and today, by the end of December 2018, we’re almost a family of 100.


Apart from the above two, there are a few other spheres too, where we levelled-up. Like we launched a brand new website of ours, a couple of months before shifting into a brand new office space. Also, since we’re already following the international method of working, we also adopted the international standards of work hours by bringing the ‘5-days working’ policy into account. We also initiated sponsoring quarterly team lunches for our AddWeb family, who after travel bonds the most over food!  


Giving Back to the Society

, ,

The universe thrives and survives on the rule of ‘give & take’ and we firmly understand the importance of the same. Hence, we do believe in giving back to the society that has given us so much to relish upon. Maybe, that is why apart from doing things for the lesser privileged on a personal ground, we also choose to do a small act of charity on an official ground. We deliberately choose to publically share it, in order to inspire others to do the same.

This year too, we gave back to society by visiting a nearby government school. We spent some really good times with the happy and giving souls there and donated some stationary products, cookies, crayons, textbooks, et all for those kids. Believe us, it was one of the most wonderful time we had throughout the entire year. Something, that’s going to stay with us for a long, long time!


The AddWeb-Drupal Association, Elevated!

, ,

Our association with Drupal is as old as our existence. In fact, we as individual team members have been Drupal-ing even before the inception of AddWeb. And this year, we took a step ahead by giving the monetary contribution to the ‘Promote Drupal Initiative’ by How could we not contribute, when it was about strengthening the community to a higher level.

And our support & passion for Drupal doesn’t end there. We also became the official ‘Supporting Partner’ of Drupal, which ultimately helped us in extending and strengthening our association with Drupal. We also made another contribution towards Drupal by organizing a ‘Drupal Meetup’ in our city and had multiple interesting knowledge-sharing sessions with the local community members.

And of course, how could we not attend the international Drupal events, worldwide! This year we attended the Standford Drupal Camp, DrupalCon Nashville, and Drupal Europe event that was voluntarily organised by the Drupal community members. We also attended our first ever Laravel event in Europe by the name of LaraCon EU.


AEDU Hits the Market, Successfully!

, ,

The joy of launching your very own dream-project is no less than winning an Oscar. Indeed! The year 2018 gave us one such moment when we launched our very own school management software - AEDU in the market. And to our surprise, it got adopted by more than 200+ schools across the nation with all love and warmth. Not just that, we also launched the Parent and Driver’s App, for the same and they also got an equal and elaborative response as the software did!


Community, Coding, Contributions & Client-Satisfaction

, ,

Last but not least! Our core passion for coding paved a path full of new endeavors and wealthy projects. Let us share these moments of pride and high spirits, from this year, with you before we all enter into a new year with goals to achieve and moments to live!

  • On one hand, when we introduced our very own Research Wing for Artificial Intelligence(AI); on the other hand, we also spent 1000+ hours on contributing towards the open-source community

  • We adapted the Intranet & Instant Communication Tool by the name of ‘’, along with developing & launching our very own ‘AddWeb Ionic Chat

  • Witnessing the boom of ReactJS and ASP.Net, we also adopted them, for we love learning and excelling at new technologies

  • We automated the DevOps process that we follow with the use of Jenkins and Ansible, resulting in being more productive and futuristic!

  • And the most momentous achievement of the year - We successfully completed 100+ projects, worldwide along with one of the biggest project of the year, named ‘AnyQuip


With a wish that we haven’t bored with our smiles, stronger bonds and success, we again wish each one of you reading this a #HappyNewYear and blissful moments, manifold!


Dries Buytaert: Soft-launching your new Drupal theme

Main Drupal Feed - Sun, 12/30/2018 - 16:22

Have you ever wanted to preview your new Drupal theme in a production environment without making it the default yet?

I did when I was working on my redesign of earlier in the year. I wanted the ability to add ?preview to the end of any URL on and have that URL render in my upcoming theme.

It allowed me to easily share my new design with a few friends and ask for their feedback. I would send them a quick message like this: Hi Matt, check out an early preview of my site's new design: Please let me know what you think!.

Because I use Drupal for my site, I created a custom Drupal 8 module to add this functionality. The module is probably too simple to share on so I figured I'd start with sharing it on my blog instead.

Like all Drupal modules, my module has a *.info.yml file. The purpose of the *.info.yml file is to let Drupal know about the existence of my module and to share some basic information about the module. My theme preview module is called Previewer so it has a *.info.yml file called

name: Previewer description: Allows previewing of a theme by adding '?preview' to URLs. package: Custom type: module core: 8.x

The module has only one PHP class, Previewer, that implements Drupal's ThemeNegotiatorInterface interface:

<?php namespace Drupal\previewer\Theme; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Theme\ThemeNegotiatorInterface; class Previewer implements ThemeNegotiatorInterface { /** * The function applies() determines if it wants to set the * active theme. If the ?preview query string is part of the * URL, return TRUE to denote that Previewer wants to set * the theme. determineActiveTheme() will be called to * ask for the theme's name. */ public function applies(RouteMatchInterface $route_match) { if (isset($_GET['preview'])) { return TRUE; } return FALSE; } /** * The function determineActiveTheme() is responsible * for returning the name of the theme that is to be used. */ public function determineActiveTheme(RouteMatchInterface $route_match) { return 'dries'; // Yes, the name of my theme is 'dries'. } } ?>

The function applies() checks if '?preview' is set as part of the current URL. If so, applies() returns TRUE to tell Drupal that it would like to specify what theme to use. If Previewer is allowed to specify the theme, its determineActiveTheme() function will be called. determineActiveTheme() returns the name of the theme. Drupal uses the specified theme to render the current page request.

Next, we have to tell Drupal about our theme negotiator class Previewer. This is done by registering it a service in

services: theme.negotiator.previewer: class: Drupal\previewer\Theme\Previewer tags: - { name: theme_negotiator, priority: 10 } tells Drupal to call our class Drupal\previewer\Theme\Previewer when it has to decide what theme to load.

A service is a common concept in Drupal (inherited from Symfony). Many of Drupal's features are separated into a service. Each service does just one job. Structuring your application around a set of independent and reusable service classes is an object-oriented programming best-practice. To some it might feel complex, but it actually promotes reusable and decoupled code.

Note that Drupal 8 adheres to PSR-4 namespaces and autoloading. This means that files must be named in specific ways and placed in specific directories in order to be recognized and loaded. Here is what my directory structure looks like:

$ tree previewer previewer ├── ├── └── src └── Theme └── Previewer.php

And that's it!