Drupal 8 Development Deconstructed
On November 19, 2015, the first officially supported version of Drupal 8 was released! Shortly after that point, there was a plethora of posts on writing Drupal 8 modules, most of them the infamous "Hello, World!" applications. Being a Drupal developer for several years, I eagerly scoured the Intertubes for information on module development with Drupal 8, reading everything I could get my hands on regarding Drupal 8 custom development.
Drupal 8 is a paradigm shift for Drupal developers, being the first release of Drupal to fully embrace object-oriented architecture in a formalized way. Leveraging the power of the Symfony2 framework, Drupal 8 has adopted the "everything is an entity" approach, and incorporating many of the powerful architectural aspects of Symfony2 into the Drupal CMS architecture. Many of the traditional Drupal constructs have undergone a major shift in implementation, leaving Drupal developers faced with relearning the way that modules and customizations are accomplished with the new iteration of Drupal.
I'm right there with you.
So, I decided to undertake a journey to convert some components of a personal project I've been working on for a couple of years now in Drupal 7, to Drupal 8, and chronicle this development online as a learning tool for Drupal developers who are looking for more than the "Hello, World" modules out there in the wild. I'll be using a couple of tools that are available to Drupal 8 developers to help jump-start the development process. I'll also attempt to explain some of the scaffolding that these tools provide in an attempt to provide some of the in-depth understanding of the components of a Drupal module that we as developers need to grasp to successfully meet the needs of our clients when customizing a solution for them using Drupal 8.
This is the first in a series of blog posts chronicling this journey. I hope you find it helpful. I welcome any feedback you may have.
Setting up a Development Environment
First off, we need a development environment. For a couple of years now I have used Vagrant VMs for development purposes, and there is a good one available to us that was built by Jeff Geerling, Technical Architect for Acquia and author of "Ansible for DevOps", called Drupal VM. You can get a copy of the VM here, if you wish to following along on this journey.
I do my development on a Mac, and just recently started learning Ansible. This VM uses Ansible playbooks for configuration, and installs a number of tools for you to stand up a local development environment, including one I will be leveraging called Drupal Console. Drupal Console is a project supported by several organizations, and is a customized version of the Symfony2 console application with some Drupal specific tools to make developing and debugging a Drupal 8 project much much easier. It is a work in progress, but it is well supported and is coming along nicely. It will definitely help you quickly scaffold custom modules for Drupal 8.
The VM build will take about 10-15 minutes, depending on your internet connection speed and your host machine configuration. The instructions for getting started with Drupal VM are very straightforward, so I won't go into those here. For our purposes, I'm calling this project "d8project", and am configuring the url "d8project.dev" for my local development environment. I'm sticking with the standard Drupal installation.
Once the VM build process is complete, you should have a fully functional base Drupal 8 site, which can be accessed through your browser at "http://d8project.dev".