The traditional Web, where websites are viewed by people on desktop computers, is obsolete. Web content is now viewed in a myriad of ways by users with mobile phones, tablets, and even watches. Content on the Internet may not be consumed directly by humans at all—web services now power apps on our phones and almost every device that's part of the emerging and much lauded Internet of Things.
Drupal is evolving to reflect the changes we're seeing on the Internet as a whole, and Drupal 8 represents a big technological leap forward for open source content management systems. Its central focus is shifting from building websites, where desktop users came first, to supporting a whole range of ways in which content is now consumed on the Internet.
Drupal 8 comes with mobile-first, responsive themes by default. HTML5 is baked in, making Drupal content viewable by any user with a device that supports a web browser. RESTful web services are included in Drupal 8 core, meaning that Drupal content can be consumed through apps or other machines, as well as through the traditional web browser.
Unsurprisingly, major changes in the way Drupal is used are accompanied by some major changes in the way you will be working with it as a developer. This book will guide you through the exciting and far-reaching changes that Drupal 8 brings. You'll learn how to build complex, powerful web applications by configuring Drupal without having to write any code. You'll also learn how to create responsive, mobile-first themes, write custom modules, and manage your Drupal projects using modern incremental development techniques.
If you're already a PHP developer, Drupal 8 is going to be an exhilarating ride for you. Modern object-orientated programming techniques that use many elements of the Symfony PHP framework are going to help you write more flexible, robust, and reusable code. The Drupal community will be attracting more and more non-Drupal PHP programmers over the coming years, as it's more elegant and cutting edge than before. Whether or not you're part of the Drupal community, there has never been a better, more exciting time to get heavily involved.
Chapter 1, Setting Up a Drupal Development Environment, walks you through the setup of a Drupal development environment as the professionals do it. You'll be introduced to a range of powerful tools that will make Drupal development more efficient and fun, and it will also help you drastically improve your productivity.
Chapter 2, Custom Module Development, gets stuck into code. You'll be writing object-orientated code to make your modules more flexible and extendable. The chapter will also cover test-driven development, which is the basis of everything you need to deploy Drupal sites that consistently do what they should.
Chapter 3, Drupal Views and Configuration Management, showcases the new configuration management system of Drupal 8, which allows you to properly separate site configuration from site content. You'll see how content types and field configuration is now done using a markup language called YAML.
Chapter 4, Introduction to the Field Types API and Developing the Custom Field Module, explores how HTML5 support has been built into Drupal 8 and the new features that this provides. You'll be building a new custom field to showcase some of these features.
Chapter 5, Theming in Drupal 8, introduces the Twig templating engine and guides you through building a fully responsive theme. The chapter will also cover theme hooks that allow you to further modify the default look and feel of Drupal 8.
Chapter 6, Enhancing the Content Author's User Experience, illustrates how Drupal 8 vastly improves the administration interface, where users have often been sadly forgotten in previous versions of Drupal. Drupal 8 isn't just for end users, it's also for editors, moderators, and administrators of the site too.
Chapter 7, Adding Media to Our Site, helps you launch a multimedia campaign by introducing a range of media elements to your site. You'll learn how to make your site more compelling and convey the required message, not only in words, but also in other types of media.
Chapter 8, How Does it Taste? – Getting Feedback, walks you through the built-in functionality of Drupal 8 to get feedback from your users. This chapter will also cover starting a two-way conversation by building a form to help your users communicate with you and submit their views or requests.
Chapter 9, Advanced Views Development, takes an in-depth look at the Views module, which you'll use in many of your Drupal projects. We'll look at how to create a custom Views plugin that uses jQuery.
Chapter 10, Drupal Project Management and Collaboration, introduces you to a place where you can make some best friends—the Drupal community. We'll look at tools for collaboration, how to get more involved in the Drupal community, and how to work as a team to build something amazing.
Chapter 11, Searching Your Site with the Search API Module, introduces some powerful search functionality provided by the Search API, a framework for extending Drupal's standard search. We'll look at what it can achieve on its own, and then take a look at Apache Solr, a third-party search engine that will make your search functionality lightning fast.
Chapter 12, RESTful Web Services in Drupal, breaks down all the boundaries of your Drupal development. You'll create a custom API using REST and an AngularJS app that will consume content from Drupal using the API. Now Drupal doesn't just need to power websites—it could power almost anything.
Appendix, Pop Quiz Answers, covers all the answers enlisted in the pop quiz sections of the book.
To follow the examples in this book, you'll need a computer on which you can set up your own development environment with a number of useful tools. All these tools are either open source or have free equivalents. The PhpStorm IDE mentioned in Chapter 1, Setting Up a Drupal Development Environment, is a proprietary and fairly expensive piece of software, but you could also use NetBeans or Eclipse as alternative IDEs, as they have comparable features.
You're also going to need an Internet connection. Many of the examples in this book rely on external services such as GitHub or PuPHPet and you'll have to do some fairly large downloads if you're installing some of the recommended software packages from scratch.
This book is aimed at people who would like to start configuring, developing, or theming with Drupal 8. Although no experience with previous versions of Drupal is necessary, you'll find many familiar Drupal concepts if you've already used Drupal 7.
For development-focused chapters, it's assumed that you have some prior knowledge of PHP and are aware of modern PHP development practices. The theming chapters will assume that you are familiar with HTML and CSS. Some experience using the command line would be useful, but not essential.
Above all, an inquisitive mind, a readiness to make mistakes, and an enthusiasm to embark on a great Drupal adventure are most important.
In this book, you will find several headings that appear frequently (Time for action, What just happened?, Pop quiz, and Have a go hero).
To give clear instructions on how to complete a procedure or task, we use these sections as follows:
Action 1
Action 2
Action 3
Instructions often need some extra explanation to ensure they make sense, so they are followed with these sections:
This section explains the working of the tasks or instructions that you have just completed.
You will also find some other learning aids in the book, for example:
These are short multiple-choice questions intended to help you test your own understanding.
You will also find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.
Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Navigate to the module page on Drupal to get the link to the latest packaged tar.gz
file."
A block of code is set as follows:
<div> <ul> <li>content 1</li> <li>content 2</li> </ul> </div>
Any command-line input or output is written as follows:
git checkout [filename] git reset --hard
New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Click on Save and then re-index your content."
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.
To send us general feedback, simply e-mail <[email protected]>
, and mention the book's title in the subject of your message.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
You can download the example code files for this book 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 files e-mailed directly to you.
You can download the code files by following these steps:
Log in or register to our website using your e-mail address and password.
Hover the mouse pointer on the SUPPORT tab at the top.
Click on Code Downloads & Errata.
Enter the name of the book in the Search box.
Select the book for which you're looking to download the code files.
Choose from the drop-down menu where you purchased this book from.
Click on Code Download.
You can also download the code files by clicking on the Code Files button on the book's webpage at the Packt Publishing website. This page can be accessed by entering the book's name in the Search box. Please note that you need to be logged in to your Packt account.
Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
WinRAR / 7-Zip for Windows
Zipeg / iZip / UnRarX for Mac
7-Zip / PeaZip for Linux
The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Drupal-8-Development-Beginners-Guide-Second-Edition. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.
To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.
Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <[email protected]>
with a link to the suspected pirated material.
We appreciate your help in protecting our authors and our ability to bring you valuable content.
If you have a problem with any aspect of this book, you can contact us at <[email protected]>
, and we will do our best to address the problem.