Drupal 8 has garnered significant community support over the last year. Many of our favorite Drupal 7 contributed modules now have stable Drupal 8 releases, making the transition to Drupal 8 a smoother and beneficial decision for many organizations. As the spring of 2017 ended, Google search traffic for Drupal 8 also surpassed that of Drupal 7. Certainly not definitive, but another telling clue for those considering transitioning to the latest release.
Let's get started with Drupal 8 basics by performing the core install. Then, we'll setup a single community contributed module.
Setting up a Drupal 8 Environment
I'm going to assume that folks reading this tutorial are familiar with a previous iteration of Drupal (ideally 7). If not, there's many ways to setup the pieces and parts on your workstation necessary to start local development. The details aren't in the scope of this tutorial. In short, you could:
- Individually setup a Linux, Apache, MySQL, and PHP (LAMP) environment on your local Windows, Linux, or Mac OS system
- Use a cloud-based server that is LAMP ready
- Leverage the Acquia Dev Desktop software to automate the environment setup process
As a team, Daymuse uses Acquia Dev Desktop to manage our local development environments. That's what I'd recommend you do as well. The software is simple to install. It automates several installation and management processes. It'll keep up with repository updates so you can quickly create Drupal sites with the latest distributions available. It also provides integration with Acquia enterprise services. This tutorial will proceed from the point of having Acquia Dev Desktop installed, working from Mac OS.
Drupal 8 Install
Let's create our first Drupal 8 install on our local workstation with Acquia Dev Desktop.
- Open the Acquia Dev Desktop app
- Select the plus ('+') symbol on the bottom left
- Click "New Drupal Site..."
- Select the latest Drupal 8 version (8.3.5 at the time of writing)
This will begin the file download and installation process of Drupal 8. This will send you over to your web browser to complete the configuration. Follow the prompts: select language, your install profile (Standard generally), confirm your system meets requirements, let Drupal configure a new database, and finally configure the site.
This information can be changed later. Don't worry about having a great site name or ideal email address just yet.
Once this process completes, you should wind up logged into your new Drupal 8 site.
If you've had any trouble working through these initial Drupal 8 core steps, feel free to reach out to me on Twitter @chrisrcooper. Once you've poked around your install, which should look surprisingly like our generally recommended admin design for Drupal 7, let's begin the process of installing a contributed module.
Setup a Contributed Module to Extend Drupal 8
Our most popular blog regarding a single contributed module is our installation and setup of Simple FB Connect in Drupal 7. Let's work through installing Simple FB Connect in Drupal 8. The configuration process of the contributed module is quite similar as it is in Drupal 7. The download and installation process is quite different since we cannot rely on Drush to do as much of the heavy lifting. In order to install Simple FB Connect, Composer -- a PHP dependency manager -- is required. This article isn't focused on the details of setting up Composer which may be different depending on your environment. However, if you're on Mac OS and are comfortable with the command line, here's the TL;DR version of other Composer tutorials:
Install and Configure Composer PHP Dependency Manager for Drupal 8
Download via Terminal and cURL:
curl -sS https://getcomposer.org/installer | php
Results should read:
We don't want to only use Composer for this single project. Let's make the composer command global:
- Copy:
sudo mv composer.phar /usr/local/bin/
- Edit your local Bash config:
vim ~/.bash_profile
- Add Composer alias:
composer="php /usr/local/bin/composer.phar"
- Relaunch Terminal
- composer command should operate now (outputs command list)
- Tell Composer where Drupal repositories are (be sure you're working from your Drupal install directory):
composer config repositories.drupal composer https://packages.drupal.org/8
Composer is now installed on your workstation, available throughout Bash, and configured to work with Drupal 8 repositories. Let's use Composer to quickly install Simple FB Connect and all of its various dependencies.
Use Composer to Install Simple FB Connect Drupal 8 Module and Dependencies
Use composer command in Terminal to install the version 3 Simple FB Connect module:
composer require "drupal/simple_fb_connect:~3.0"
This may take some time as Composer initializes the Drupal repositories, results should read:
As you can see from the results, Composer did a lot of heavy lifting in installing various external dependencies that Simple FB Connect has. Phew! Take a break.
Configure a Drupal 8 Module
Now, let's enable and configure the Simple FB Connect module in our Drupal 8 installation.
Use Drush to enable the new module (or do so from your Extend page /admin/modules):
drush en simple_fb_connect -y
Confirm the module is enabled. Go to your Extend page: /admin/modules. You should see:
Clear the site's cache so that configuration options will be visible:
- Via Drush cache rebuild (note: "drush cc all" no longer works as in Drupal 7):
drush cr
- Or via the Performance page (/admin/config/development/performance) and "Clear all caches" button
Confirm that the Simple FB Connect module permissions are configured correctly on the Permissions page (/admin/people/permissions).
Now you will need to configure Simple FB Connect's module configuration options. Our Drupal 7 tutorial for Simple FB Connect walked through the process of creating a Facebook App which is required for this module to connect to. The process hasn't changed. You can follow the Create Facebook App portion of the old tutorial if you don't already have a Facebook App to use. Once you've setup a Facebook App, you can use the credentials to fill out the module configuration.
Module configuration page (/admin/config/people/simple-fb-connect):
Allow Anonymous Visitors to Login with Facebook in Drupal 8
You'll want to allow Visitors (anonymous users) to login with their Facebook accounts in order to test the module and your Facebook app. Enable Visitors for Registration and Cancelation on the Account Settings page (/admin/config/people/accounts).
Visit the login page from a fresh browser. Attempt to login with your own Facebook account.
Once you've entered your Facebook login info, if you're successful, you should see your account logged into the Drupal site with your Facebook account name.
Congratulations! You've setup a development environment compatible with Drupal 8, Drupal 8 itself, and a contributed module to extend the capabilities of the CMS. You've also setup Composer which will be a useful tool as you work with other complicated PHP projects or Drupal contributed modules.
User Experience and Social Media Logins in Drupal 8
The primary reason you're integrating Facebook's login system is to improve the user experience. You may need to manually prune your user accounts for spam, but it may be worth it to continue to allow users to login (and register) with their Facebook accounts without approval. If a user has to wait for manual administrator approval, they may never bother to return once you've approved them.
We're working to develop tutorials to integrating Facebook throughout your Drupal 8 site. In the meantime, have a look at our Drupal 7 tutorials regarding Facebook:
If you're interested in thoroughly integrating Facebook with your Drupal website strategy through professional services, reach out. Think this tutorial is useful? Don't forget to share!