You are previewing Drupal 8 Development Beginner's Guide - Second Edition.
O'Reilly logo
Drupal 8 Development Beginner's Guide - Second Edition

Book Description

Develop your programming skills by creating engaging websites using Drupal 8

About This Book

  • Explore the new features of Drupal 8 through practical and interesting examples while building a fully functional recipe sharing website

  • Learn about web content management, multi-media integration, and the newly introduced native web services in Drupal 8

  • A hands-on, example-driven guide to developing Drupal websites that covers everything from site building, theme development, creating custom modules, as well as the development environment

  • Who This Book Is For

    If you are a developer who wants to use Drupal to enhance your website project and web application to manage content, this book is for you. Whether you are new to Drupal or an experienced web developer, you will be able to master both basic configuration and advanced module development in Drupal through this book.

    What You Will Learn

  • Set up your Drupal development environment

  • Brush up on your understanding of the concepts of object-oriented programming, module development, and test-driven development

  • Install and configure Drupal, add new content type, and work through lot of dummy content to create listing pages using views

  • Enhance the content author’s user experience and custom block

  • Find out about field Type API and explore custom theme development

  • Manage various media types in Drupal for your content-rich website

  • In Detail

    Drupal is one of the most popular platforms with which to develop websites. With more and more organizations looking to build engaging digital experience for their stakeholders, the Drupal Content Management System offers a mobile-first platform with native support for integrations, better performance, and scalability. The new version brings significant changes to its module development and theme creation techniques, improving performance and refining the development experience.

    This book will help you develop your own website using Drupal 8 in a step-by-step manner. You’ll start off by setting up your development environment, enabling you to begin writing custom code for a Drupal-powered website through PHPStorm. You will learn about configuration management and creating custom content types before exploring the HTML5 features included with Drupal 8.

    You will then get familiar with Drupal 8’s mobile-first features, explore the built-in WYSIWYG and in-line editing capabilities of Drupal 8, and enhance the overall authoring experience. Later, you will create and enhance a Media Entity Lightbox module, before taking an in-depth look at the Views module.

    We then cover some advanced search concepts and walk you through the installation and integration of the Java-based Apache Solr search engine. Finally, you will explore and configure the built-in support for REST and extend its support by installing the RESTful module. By the end of the book, you will have created a recipe sharing website while gaining a solid understanding of development best practices for Drupal 8.

    Style and approach

    Each chapter provides examples in a sequential manner from basic to advanced, and each example is explained using easy-to-understand language and a step-by-step approach. This programming experience will enable you to create a wide range of content authoring as well as end user experience.

    Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

    Table of Contents

    1. Drupal 8 Development Beginner's Guide Second Edition
      1. Table of Contents
      2. Drupal 8 Development Beginner's Guide Second Edition
      3. Credits
      4. About the Authors
      5. About the Reviewer
      6. www.PacktPub.com
        1. eBooks, discount offers, and more
          1. Why subscribe?
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Sections
        5. Time for action – heading
          1. What just happened?
          2. Pop quiz – heading
          3. Have a go hero – heading
        6. Conventions
        7. Reader feedback
        8. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      8. 1. Setting Up a Drupal Development Environment
        1. Installing Drupal for local development
        2. Time for action – installing Drupal using Acquia Dev Desktop
          1. What just happened?
          2. Installing Drupal the localhost way
        3. Time for action – installing a Mac OS X AMP stack
          1. What just happened?
        4. Time for action – installing a Windows AMP Stack
          1. What just happened?
          2. PHP configuration
        5. Time for action – modifying the php.ini settings
          1. What just happened?
          2. Modifying the MySQL my.cnf settings
        6. Time for action – setting up MySQL for Drupal
          1. What just happened?
        7. Time for action – creating an empty MySQL database
          1. What just happened?
        8. Installing Git
        9. Time for action – installing Git for Mac OS X
        10. Time for action – installing Git for Windows
          1. What just happened?
        11. Installing Drush
        12. Time for action – installing Drush for Mac OS X
        13. Time for action – installing Drush for Windows
        14. Installing Drupal 8
        15. Time for action – installing Drupal 8
          1. What just happened?
        16. Installing the PHPStorm IDE
        17. Time for action – installing the PHPStorm IDE
        18. Time for action – creating a new PHPStorm project
        19. Drupalize PHPStorm IDE
        20. Drupal from a developer's perspective
        21. Installing Vagrant
        22. Time for action – installing Vagrant
          1. What just happened?
        23. Summary
      9. 2. Custom Module Development
        1. Creating custom Recipe content type
        2. Time for action – creating custom content type
          1. What just happened?
        3. Time for action – adding a new recipe
          1. What just happened?
          2. OOP concepts in Drupal
        4. Time for action – developing a custom module in Drupal 8
          1. What just happened?
        5. Time for action – developing custom field formatter
          1. What just happened?
        6. Test-driven development (TDD)
          1. PHPUnit tests for Drupal classes
          2. Functional tests
        7. Time for action – writing and testing functional test from our d8dev custom module
          1. What just happened?
        8. Summary
      10. 3. Drupal Views and Configuration Management
        1. A quick introduction to Views
        2. Time for action – creating a recipe listing block using views
          1. What just happened?
        3. Configuration management in Drupal 8
        4. Using the Configuration Management interface
        5. Time for action – importing, exporting, and synchronizing configurations
          1. What just happened?
        6. Working of Configuration Management in Drupal 8
        7. Changing the active configuration storage
        8. Introducing the Devel module
          1. Installing the Devel module
        9. Time for action – generating dummy content using the devel_generate module
          1. What just happened?
        10. Summary
      11. 4. Introduction to the Field Types API and Developing the Custom Field Module
        1. Introducing the NutritionInformation module
        2. Time for action – developing a custom module for a compound NutritionInformation field
          1. What just happened?
        3. Time for action – updating the Recipe content type to use the NutritionInformation field
          1. What just happened?
        4. Summary
      12. 5. Theming in Drupal 8
        1. What is a theme?
        2. Time for action – creating a sub-theme
          1. What just happened?
          2. An overview of Bartik
        3. Mobile first, responsive themes
        4. Time for action – installing Drush
        5. Time for action – Adding assets to your theme
          1. What just happened?
        6. Time for action – calling assets on specific pages
          1. What just happened?
        7. Introduction to templating and Twig
          1. Theme hook suggestions
          2. File and function names
          3. Brackets syntax
          4. Rendering
          5. Filters
          6. Control structures
        8. Debugging Twig
          1. HTML comments in markup
          2. Debugging variables
          3. Kint
        9. Time for action – Twig in practice
          1. What just happened?
        10. Time for action – understanding the benefits of contributed modules
          1. What just happened?
        11. What are contributed modules?
          1. How do I know whether a module is safe to use?
          2. Is it better to use a contrib module or custom code?
        12. Summary
      13. 6. Enhancing the Content Author's User Experience
        1. A quick introduction to CKEditor in Drupal 8
        2. Configuring CKEditor profiles
        3. Time for action - adding some buttons to the basic HTML profile
          1. What just happened?
        4. Time for action - exporting CKEditor configuration
          1. What just happened?
        5. Adding a new CKEditor profile
        6. Time for action - creating a text-only control profile for anonymous users
          1. What just happened?
        7. Classic editor and inline editing
        8. Time for action – using inline editing
        9. Adding widgets to CKEditor
          1. Have a go hero - create a CKEditor plugin and allow Drupal to discover it
        10. Introduction to the Block API for Drupal 8
        11. Time for action – creating a block to aid the authoring experience
          1. What just happened?
        12. Time for action – including default configuration in your module
        13. Summary
      14. 7. Adding Media to Our Site
        1. Introduction to the File entity module
        2. Working with dev versions of modules
        3. Time for action – installing a dev version of the File entity module
          1. What just happened?
        4. A new recipe for our site
        5. Time for action – adding a Recipe images field to our Recipe content type
          1. What just happened?
        6. Creating a custom image style
        7. Time for action – adding a custom image style through the image style administrative page
          1. What just happened?
        8. Time for action – creating a programmatic custom image style
          1. What just happened?
        9. Integrating the Colorbox and File entity modules
        10. Time for action – installing the Colorbox module
          1. What just happened?
        11. Working with Drupal issue queues
        12. Time for action – creating an issue for the Colorbox module
          1. What just happened?
        13. Summary
      15. 8. How Does It Taste? – Getting Feedback
        1. Introduction to the Drupal contact form
        2. Time for action – enabling and configuring the core contact form
          1. What just happened?
        3. Adding placeholder text to our contact form
          1. Using configurations to add placeholder text to the contact form
        4. Time for action – adding placeholder text to our site contact form
          1. What just happened?
        5. Using custom code to add placeholder text to the Name and Email fields
        6. Time for action – adding placeholder text to Name and Email fields
          1. What just happened?
        7. Time for another recipe!
        8. Colorbox file enhancements
        9. Time for action – enhancing the Colorbox module with image title and alt captions
          1. What just happened?
        10. Contributing our code to Drupal
        11. Time for action – creating a patch and uploading it on the Drupal issues queue
          1. What just happened?
        12. Recipe reviews with comments
        13. Time for action – configuring comments as recipe reviews
          1. What just happened?
        14. Time for action – enhancing the liking system using comments and views
          1. What just happened?
        15. Summary
      16. 9. Advanced Views Development
        1. Views revisited – advanced configuration
        2. Random top rated recipe block
        3. Time for action – building a random top rated recipe block with Views
          1. What just happened?
        4. Taxonomy-based View with tabs
        5. Time for action – creating a cuisine vocabulary to organize recipes
          1. What just happened?
        6. Time for action – creating a Recipes by cuisine type Views block
          1. What just happened?
        7. Time for action – installing and using the Views Field View module for our Recipe by Cuisine Type View
          1. What just happened?
        8. Tabbed Views display
        9. Time for action – developing a Views style plugin for semantic tabs
          1. What just happened?
        10. Time for another Recipe
        11. Contributing the Views semantic tabs module to Drupal
        12. Time for action – creating a sandbox for the views semantic tabs module
        13. Summary
      17. 10. Drupal Project Management and Collaboration
        1. Rotating banners with the Views Slideshow module
        2. Time for action – installing the Views Slideshow module
          1. What just happened?
        3. Creating a rotating banner with Views Slideshow
        4. Time for action – creating a banner using the Views Slideshow module
          1. What just happened?
        5. Time for action – creating a new image style for images in our rotating recipe banner
          1. What just happened?
        6. Enhancing the appearance of our front banner with a pager and CSS
        7. Time for action – updating the front banner view to include a slide show pager
          1. What just happened?
        8. Time for another recipe
          1. Promoting a sandbox project to a full project
        9. Time for action – creating README.txt and pushing to the sandbox
          1. What just happened?
        10. Time for action – promoting the Views semantic module to a full project on Drupal.org
          1. What just happened?
        11. Introducing the Features module
        12. Time for action – installing the Features module
          1. What just happened?
          2. Recipe feature by the Features module
        13. Time for action – using the Features module to export the Recipe content type and related configurations
          1. What just happened?
        14. When to use core Configuration Management compared to Features
        15. Summary
      18. 11. Searching Your Site with the Search API Module
        1. The Drupal core search
        2. The Search API module
        3. Time for action – basic installation and configuration of the Search API module
          1. What just happened?
          2. An explanation of search servers and search indexes
          3. Search server
          4. Search index
          5. Fields
          6. Processors
          7. Populating your search index
        4. Exposing the search to users
          1. Altering the search display
          2. Excluding entities from being indexed
        5. Installing Apache Solr as the search backend
          1. Installing Solr 4.x on a virtual machine with Vagrant and Puppet
        6. Time for action – creating and configuring your virtual machine
          1. What just happened?
          2. Installing Solr 5.x manually on Ubuntu 14.04
        7. Time for action – installing and configuring Solr on Ubuntu
          1. What just happened?
        8. Securing Apache Solr with Uncomplicated Firewall
        9. Time for action – configuring Uncomplicated Firewall
          1. What just happened?
        10. The Search API Solr module
        11. Time for action – configuring Drupal to use Apache Solr
          1. What just happened?
          2. Using the read-only mode
        12. Search facets
        13. Time for action – building faceted search blocks
          1. What just happened?
          2. Have a go hero
          3. Pop quiz
        14. Summary
      19. 12. RESTful Web Services in Drupal
        1. Introduction to web services
        2. Introduction to REST
        3. Headless Drupal
          1. When to decouple Drupal or when to use Headless Drupal
        4. RESTful web services in Drupal
          1. RESTful APIs in Drupal
        5. Time for action – getting all the recipe types
          1. What just happened?
        6. Time for action – creating an API to get all the recipes under a recipe type
          1. What just happened?
        7. Time for action – consuming RESTful web services using AngularJS
          1. What just happened?
        8. Summary
      20. A. Pop Quiz Answers
        1. Chapter 11 – Searching Your Site with the Search API Module
          1. Pop quiz
      21. Index