Probably every experienced Drupal programmer has a slightly different definitionof the Drupal Way of programming, although there are many commonalities. Myinterpretation of the Drupal Way is set out in ; Ive tried to stick to the commonalities inthe definition that most Drupal programmers would agree on.
Intended Audience
The first edition of this book waswritten primarily for people with a background inprogramming whoare new to using and programming with Drupal. If you fitthis profile, the mainreason to read this book is that whatever your programming background, yourexperiences have taught you certain lessonsand only some of them apply wellto Drupal. My main goal in the first edition was to make you aware ofwhich lessons are which, and helpyou make a successful transition to being an expert Drupal programmer: someonewho knows just how and where to apply your programming skills to have thegreatest effect.
The second edition of this book retains this goal, butis also aimed at experienced Drupal 7programmers who want to make the transition to Drupal 8. Because both Drupal 7and Drupal 8 are included in this book, programmers who fit this profile will beable to compare the Drupal 7 programming methods, APIs, and concepts that theyare familiar with to their Drupal 8 equivalents.
In addition, this book should be useful for the following audiences:
- Anyone working with Drupal who wants to understand how it works under the hood.
- Drupal site builders and themers who have realized they need to do some programming for customization, and want to do it the Drupal way.
- Drupal users who want to contribute to the Drupal open-source project by programming.
The back end of Drupal and most of its code is written in PHP, utilizing somevariety of SQL for database queries. Accordingly, this book concentrates on PHPand database programming for Drupal, although there are definitely opportunitiesto program in Flash, JavaScript, and other front-end languages with Drupal.
Because this book was written for a programming audience, itassumes knowledge of the following:
- The basics of the Web and HTTP requests.
- The basics of PHP programming and programming in general (standard programming terminology is not explained).
- Object-oriented programming in PHP, especially for the Drupal 8 sections.
See to find resources about these topics, if you needadditional background.
Warning
The second edition of this book is currently an early e-bookrelease rather than a fully finalized edition. I believe it to be accurateas of the time of publication, and I wanted to make it available now for peopletrying to learn Drupal 8 and port their Drupal 7 modules to work with theearly Beta releases of Drupal 8.But Drupal 8 is still changing, so some of theDrupal 8 material in the book will probably become outdated as Drupal 8 movesthrough the Beta process. Ill be watching Drupal 8s progress and makingupdates to the book as needed, so be sure to check back on the books web siteand update your copy! See .
How to Use This Book
In order to get the most out of this book, I would suggest that you start byreading .
Then Id suggest reading , which is a comprehensive set ofprogramming examples covering Drupal core (the base Drupal system, notincluding add-on modules). The Examples project is maintained by manycontributors within the Drupal community, and it is an excellent resource.
After reading about Drupals principles and common mistakes, look through so you know whats there, and then come back toindividual topics and examples when you need them. Of course, this book wouldnever be able to cover every possible topic in Drupal programming, so if youfind you need an example that isnt covered here, try the Examples forDevelopers project. If it isnt covered there either, there are many Drupalprogrammers who blog, so a web search may be helpful.
Finally, for more details.
Tip
All of the code in this book is available for download from thebooks web site. The downloaded code contains additional documentation headersand test code beyond what is included in the book. See .
Drupal Versions
Every few years, the Drupal project releases a new major version of Drupal(Drupal 6, Drupal 7, and so on). Each major version of Drupal brings large,incompatible changes to the architecture and API, and generally, programmingthat you do for one major version cannot be used without modification in othermajor versions. Contributed modules (additional modules downloaded fromdrupal.org) also make large, incompatible architectural and API changes withtheir releases (Views 6.x-2.x versus 6.x-3.x, for instance).
The code samples in this book are compatible with either Drupal 7 or Drupal 8 asnoted, and with particularDrupal 7 or 8 versions of contributed modules as noted in theirsections. The descriptive sections of this book are also writtenprimarily with Drupal 7 and 8 in mind.
Conventions Used in This Book
The following terminology conventions are used in this book:
- While on some operating systems directories are called folders, this book always refers to them as directories.
- Sample site URLs use example.com as the base site URL.
- Sample modules have machine name
'mymodule'
, and sample themes have machine name 'mytheme'
.
The following typographical conventions are used in this book:
Italic Indicates new terms, URLs, email addresses, filenames, and file extensions. Constant width
Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords. Constant width bold
Shows commands or other text that should be typed literally by the user. Constant width italic
Shows text that should be replaced with user-supplied values or by values determined by context.
Tip
This icon signifies a tip or suggestion.
Note
This icon signifies a note.
Warning
This icon indicates a warning or caution.
Using Code Examples
This book is here to help you get your job done. In general, if this book includes code examples, you may use the code in this book in your programs and documentation. You do not need to contact us for permission unless youre reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from OReilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your products documentation does require permission.