Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Drupal 8 Blueprints
Drupal 8 Blueprints

Drupal 8 Blueprints: Step along the creation of 7 professional-grade Drupal sites

eBook
€17.99 €26.99
Paperback
€32.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Drupal 8 Blueprints

Introduction and Getting Set Up

Welcome to Drupal 8 Blueprints!

I'm Alex Burrows, and I'll be your guide for this journey through building websites using Drupal 8.

Firstly, this book is aimed at beginner to intermediate-level developers. You'll need an understanding of how websites work and some PHP knowledge, as we will later delve into writing some custom modules, but mostly, this book will use Drupal's powerful configuration.

Throughout the book, we will go over things we covered earlier; however, the aim is to understand the basics and, if at any time, you become unsure, review the chapter where it was covered.

We will cover the following to get you ready to build websites using Drupal 8 first:

  • Setting up for local development:
    • Setting up on Windows
    • Setting up on macOS
  • What is SSH?
  • Our great development tools:
    • Homebrew
    • iTerm
    • Oh MyZsh
  • Setting up our local development environment:
    • Native
    • Acquia DevDesktop
    • Vagrant
    • Docker
  • Terminology
  • Drush and Drupal Console
  • Installing Drupal:
    • Getting our basic site
    • Drupal core structure
    • Downloading modules and themes
    • Using themes
  • Get involved with Drupal

So, get ready to learn and build some awesome websites using Drupal 8!

Setting up for local development

As we will start a site that requires PHP and MySQL to run, we need to set up a local development environment.

There are many ways that this can be achieved; the most favorable ones are Vagrant and Docker. Oh, and of course, if you're developing a Drupal site, Acquia DevDesktop is a good option as well. This book is highly focused on you developing Drupal on a macOS; however, there are other explanations on how to do this on Windows, and Acquia DevDesktop works on Windows. I will explain how to set up shell on Windows as well, but the only local tool I recommend for now is Acquia DevDesktop as I have had many issues with Vagrant on a Windows machine.

Setting up on Windows

Setting up on macOS

As a developer, I love macOS, because for me it just works. I have multiple tools that I use and highly recommend, which I will go into more depth further on in this chapter.

What is SSH?

Secure Socket Shell, otherwise known as (SSH), allows us to access our directories and files on our operating system, whether it's on our local development environment or our live web server.

In order to do this on macOS, we need to launch the Terminal application. On Windows, we can use the Bash application that was explained earlier.

We can execute commands with SSH to do this; for example, we can change to another folder/directory using the following:

cd mydirectory

Alternatively, we can create a new folder/directory using this:

mkdir mydirectory

These are just some examples of SSH commands, and I encourage you to take a look into this.

When we are doing this development, especially where we are using dynamic code such as PHP, we need to be able to add other tools using the command line.

Our great development tools for macOS

There are some very important tools that I use for development. These not only make my processes quicker, but they also allow me to enhance my development environment to how I need it.

An example of this is that if I might need to install an add-on quickly, I can do this using Homebrew.

Some of the helpful add-ons I use are as follows:

  • Homebrew
  • iTerm
  • Oh My Zsh

Homebrew

The first important tool is HomeBrew (no, it's not teaching you how to make some alcohol at home). It is a fantastic addition to the shell that allows us to execute and install packages very easily.

If you go to https://brew.sh, you can copy and paste into Terminal and away you go, with very simple commands, such as the following:

brew install curl

What the preceding command will do is to download and install the curl package for us. This is just an example of what it does.

iTerm

As it says on their website:

"iTerm2 is a replacement for Terminal and the successor to iTerm. It works on Macs with macOS 10.8 or newer. iTerm2 brings the Terminal into the modern age with features you never knew but always wanted."

This allows us to make our experience using the Terminal a lot better (https://www.iterm2.com).

Oh My Zsh

This allows us to run commands and shortcuts. We don't have to type out full commands, as we did earlier, and we can use our own commands and shortcuts to achieve tasks a lot quicker (http://ohmyz.sh).

Setting up our local development environment

As with anything, there are a lot of choices for local environments. These are just samples of the ones that are there and what they do.

Native

As macOS is built on a Unix framework, you can use this entirely to run your local host, and its just a case of editing some files on your mac and changing them. There is some great documentation on this at (http://php.net/manual/en/install.macosx.bundled.php).

Acquia DevDesktop

This is an all-inclusive application that allows you to get started and set up with making your Drupal websites locally. We will indeed use this for the entire book. It creates the URL for your local website as well as the database and Drupal core.

We use this at Drupal events, and we are mentoring people new to Drupal (https://www.acquia.com/gb/products-services/dev-desktop).

The next two require VirtualBox. This allows us to create virtual machines on both mac and Windows. From here, we can create our separate machines and download OS images that will allow us to install Linux OS, or if you have a Windows disk, you can install this (https://www.virtualbox.org/wiki/Downloads).

Vagrant

This allows you to create and define what your virtual machine will have and require (https://vagrantup.com).

Vagrant provides the same easy workflow regardless of your role as a developer, operator, or designer. It leverages a declarative configuration file that describes all your software requirements, packages, operating system configuration, users, and more.

One great VM to use for Drupal can be found at (https://www.drupalvm.com).

I personally use this for all local development.

Docker

This again allows you to create and define what your development environment will have, but it uses a thing called containers to achieve this (https://www.docker.com).

Using containers, everything required to make a piece of software run is packaged into isolated containers. Unlike VMs, containers do not bundle a full operating system; only libraries and settings required to make the software work are needed. This makes for efficient, lightweight, self-contained systems and guarantees that the software will always run the same, regardless of where it's deployed.

Terminology

Within Drupal and the community, there is some terminology that we use; the following are some of them along with what they mean:

  • Content type: This is an entity type, and the individual content types within it are called bundles; in this case, we have a basic page bundle and an article bundle by default
  • Node: A node is a piece of content; this is usually within a content type, and a content type is indeed an entity type
  • Taxonomy: This is another name for a category, so we can distinguish types of content based on the category name; this is usually used for filtering content
  • Themes: This is what makes our site look the way it is
  • Modules: Another name for a plugin that adds functionality to Drupal

Drush and Drupal Console

In Drupal, we have some powerful tools that allow us to run commands to execute on our website. This is all run using the command line; an example of this is that we can download themes and modules directly off Drupal.org just by running one command.

Both Drush and Drupal Console are very similar in what they do, and it's down to preference as to which you prefer. For this book, we will use Drupal Console.

Installing Drupal

For now, we will just install Drupal using DevDesktop; however, we will change how we do this later on.

To do this, open up DevDesktop, then bottom left click on +, and then select New Drupal Site. Then, once the popup appears, click on Install in the row that Drupal 8 is in. This will appear with a popup:

Fig 1.0: Install Drupal 8.x site

Once this is done, click on the Local site:

Fig 1.1

In the preceding Fig 1.1, we can now get our Drupal site up and running.

We can see four lines of content:

  • Local site: This is the URL that our website is accessible on locally
  • Local code: This is where our code is currently located; further along, there is a little square button on the right, which launches a Terminal window
  • Local database: This is the name of our database
  • PHP version: This is the version of PHP being used

Getting our basic site

Now that we have downloaded and set up our Drupal site to work on our local environment, let's begin installing our site.

The installer will ask various questions; however, as we are using DevDesktop, we don't need to enter any database connection details, but when we use this on a different local environment or even our production environment, it is all required.

Drupal core structure

In Drupal, we have several locations where our contrib and custom code go. The following figure illustrates the directory and file structure for Drupal 8.x core:

All custom and contrib items need to go into either modules, profiles, or themes.

The recommended structure inside these directories to add the contrib and custom directories. Consider the following examples:

  • Modules:
    • /modules/contrib
    • /modules/custom
  • Profiles:
    • /profiles/contrib
    • /profiles/custom
  • Themes:
    • /themes/contrib
    • /themes/custom

There are other key directories here that don't need to be touched, but there is also a sites directory, which contains our sites configuration to access the database, files storage, libraries, and services.

Downloading modules and themes

Once our site is installed, we need to download our base theme for our site, so we can do the following to get modules or themes:

https://drupal.org/project/{module or theme name}

  • Download using Drush

drush dl project, for example, drush dl bootstrap

  • Download using Drupal console

drupal:download project

Using themes

With Drupal, we can start a site without writing any code for a theme, as Drupal core comes with the following accessible themes:

  • Bartik
  • Seven
  • Stark

Apart from these three, there are two others that are used as the entire base of Drupal core--Stable and Classy.

Classy is a subtheme of stable, makes Drupal look the way it does, and adds classes.

However, we want to get started with our own theme. So to do this, we need to open Terminal. As stated earlier, the button in DevDesktop on the right-hand side will launch our Terminal window.

Once this is open, we can download our modules and themes straight into our Drupal site. For this book, we will use Bootstrap as our base theme and then create our own theme:

drush dl bootstrap

This will download the Bootstrap theme (https://drupal.org/project/bootstrap) into our themes directory.

Now that we have Bootstrap downloaded, let's create a really basic theme so that we can add onto it later on. Inside our /themes/custom directory, create a new directory called blueprint.

This is where our custom theme will be stored; inside this, we have the ability to add our frontend structure, which includes our templates, CSS, and Javascript.

Start by creating a file called blueprint.info.yml; note that we have it structured as THEMENAME.info.yml.

In Drupal 8.x, we have adopted the use of YAML files, and you will note that all configuration in Drupal uses this format.

blueprint.info.yml

name: Blueprint
description: Bespoke theme for Drupal 8 Blueprints
type: theme
core: 8.x
base theme: bootstrap
# Regions

What this does is to tell Drupal: Hey I'm a new theme, this is what I do. It's set out like this:

  • Name: This is what we are calling our theme, following the same name we have given to our themes directory.
  • Description: This is a simple description of the theme, and it shows in the Drupal admin interface.
  • Type: This is saying that this is for a theme; if it was for a module, it would be module instead.
  • Core: As this is for Drupal 8, we need to specify that it is for Drupal 8.x.
  • Base theme: We are leveraging our theme files, styles, JavaScript, and templates off of the bootstrap library. This, of course, can be based on any other theme.

Now that we have done this, we are ready to start making a Drupal site and add it to our custom blueprint theme later on.

Getting involved with Drupal

Before we continue, it is recommended that you register at Drupal.org and set up a profile; this will help you vastly and will allow you to ask questions on Drupal.org, fix bugs, submit bugs, and become part of a fantastic community.

Within the Drupal community, we have two sayings:


Come for the code, stay for the community.

There's a module for that!

Let's get Drupal started!

So, now that we have set up our first Drupal site, we can start with our first website!

There is a lot to learn in this book, so take your time.

Ensure that you have a caffeinated drink to hand or a glass of water, and enjoy unravelling the true power of Drupal!

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Create and design your own customized website effortlessly and efficiently
  • This up-to-date guide on Drupal 8 will show you how you can leverage the latest Drupal 8 features
  • This hands-on guide will turn you into a professional grade Drupal 8 developer through 7 unique and engaging web sites

Description

Drupal is an open source content management framework that can be used for developing websites and simplifying online management of content for users. This book is a must-have for web developers who are looking to create professional-grade websites using Drupal 8. While building 7 different Drupal websites, we will focus on implementing the out of the box features that come with Drupal 8 and see how we can make some complex sites with minimal custom code. Focusing completely on Drupal 8, this book will help you leverage the new Drupal 8 features such as creating a different types and layouts of content using configuration to build in core with its built-in web services facilities, and effortless authoring using the new CKEditor with an effortless and efficient industry standard approach. The book starts with getting started with the development environment of Drupal. Each chapter will start with a brief overview of the site to be built and the required features. Then, we will proceed to create customized modules and themes and integrate third-party plugins. Lastly, you will learn about "headless" Drupal that uses RESTful services that would help you to display content outside of Drupal By the end of the book, you will be able to implement the knowledge gained to build your own custom websites using Drupal 8.

Who is this book for?

This book is ideal for web developers who are looking to create professional web applications using Drupal 8. You should have some previous experience with Drupal and must have a basic knowledge of web application development in general. If you are looking to create fluent professional websites that will take you to the next level, then this book is for you.

What you will learn

  • Find out how to use the Drupal 8 core functionality to build great websites
  • Discover how to better manage content using custom blocks and views
  • Display content in multiple ways, taking advantage of display modes
  • Using the new TWIG theme engine for Drupal
  • Easily manage and filter content
  • Understanding best practices for building great Drupal sites
  • Move beyond Drupal to build headless websites using RESTful services and JavaScript frameworks

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Sep 22, 2017
Length: 262 pages
Edition : 1st
Language : English
ISBN-13 : 9781785887567
Languages :
Concepts :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Sep 22, 2017
Length: 262 pages
Edition : 1st
Language : English
ISBN-13 : 9781785887567
Languages :
Concepts :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 106.97
Drupal 8 Development Cookbook
€36.99
Drupal 8 Blueprints
€32.99
Mastering Drupal 8
€36.99
Total 106.97 Stars icon

Table of Contents

8 Chapters
Introduction and Getting Set Up Chevron down icon Chevron up icon
Telling Your Own Story with Drupal Chevron down icon Chevron up icon
Get Fundraising with Drupal Chevron down icon Chevron up icon
Recruit Using Drupal Chevron down icon Chevron up icon
List Properties with Drupal Chevron down icon Chevron up icon
Express Your Event with Drupal Chevron down icon Chevron up icon
Get Teaching with Drupal Chevron down icon Chevron up icon
Go Static with Drupal Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Half star icon Empty star icon Empty star icon Empty star icon 1.5
(2 Ratings)
5 star 0%
4 star 0%
3 star 0%
2 star 50%
1 star 50%
pngwen Aug 15, 2018
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
This book starts strong, but rapidly falls apart. Code examples are incorrect in places, and as the narrative continues they become incomplete. For instance, around page 89 we get the following:"The next part of a form is the submit handler; we do this by adding a submitForm() method. This takes arguments that we can use inside this method. If we want to display a value from the submitted form, then we will use $form_state. What we will do now is just display a message saying Donation added..."The arguments to the submitForm method are never revealed to the reader, nor is there any explanation of how to display this message. This means that in order to complete the code, the reader has to paw over massive amounts of API documentation, which completely negates the value of the tutorial to begin with.The only reason I gave this book 2 stars is that in some places, it does provide useful information. It would be handy if you were a well seasoned drupal 8 developer who was a few months out of practiced. If you are trying to learn drupal 8, then this is not the book for you.
Amazon Verified review Amazon
BR Dec 27, 2017
Full star icon Empty star icon Empty star icon Empty star icon Empty star icon 1
The book claims it is meant for people with "some" PHP and drupal knowledge. Definitely anyone will struggle to cope with the examples if they follow the instructions given in the book as is. Lacks comprehensiveness, misleading and not dealt with all important features introduced in drupal 8. Poorly edited, sentence form errors etc.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.