In Drupal 10.2, you’ll notice a new UI when you create a new field. It’s designed to help you recall what each field type means, so that you can make the right choice. Let’s check it out.
PHP Attributes for Drupal Plugins
Blog postAs of PHP 8.1, the PHP language has native support for attributes that are compatible with Drupal’s plugin system use case. As a result, Drupal will transition from the use of annotations to PHP attributes, to supply metadata and configuration for plugins. This will require developers to learn the new PHP attributes syntax, and update their existing code to use it. For now, Drupal will continue to support both annotations and attributes. But the proverbial clock is ticking.
So let’s take a look at how we got here, and what you’ll need to do to update your code for future versions of Drupal.
We've made it to the final blog post (for now?) in our spotlight on Symfony in Drupal. In this blog post, we'll take a look at Symfony's utility components. We're using this term to group together Symfony components that provide useful functionality. It's a great idea to familiarize yourself with these. You can make use of them in your own modules, or bring them into other PHP application code.
In this installment of our series on Symfony's role in Drupal, we're focusing on the Routing component. Even if it may seem simple looking from the outside, routing in Drupal is a complex task with lots of customized parts. The routing component's job is to match incoming requests to the correct controller, which is then responsible for building the response. Let's take a high-level glance at how Drupal has built upon Symfony's Routing component.
Registration is now open for our next 2 workshops on Drupal migrations and theming! Learn to use Drupal's Migrate API to upgrade from Drupal 7 to Drupal 10, February 26-28, 2024. Learn to create stunning Drupal 9 and 10 themes, March 13-15, 2024.
These remote workshops will happen 100% online via Zoom and other tools. We think you’ll get the most out of it if you come prepared to engage with the instructors and other participants.
They are broken up into 3 distinct 2.5-3 hour units instead of one long 8-hour workshop.
Each workshop unit will consist of a combination of instructor presentation, hands-on exercises, and instructor-lead group discussion. The units build upon one another so you’ll want to be able to attend all 3 days of the workshop you select.
In Part 2 of our exploration of Symfony components in Drupal, we focus on the event dispatcher.
The event dispatcher is a tool that enables the application to communicate across objects by subscribing to and listening for events. It achieves this by creating a directory for various event types, and the corresponding registered listeners for each event type. When a specific type of event occurs, the code that has registered a listener for that event is invoked. If you're familiar with the Mediator and Observer design patterns you might recognize similarities here.
For over a decade, Drupal has been using Symfony Components. In 2015, with the release of Drupal 8, these components became a part of Drupal's core software. It's possible to build complex Drupal sites without worrying about what these components do. But learning about the system we're using will make us better developers of Drupal sites and other PHP applications.
In this first part of a 3-part series, we'll explore how Symfony helps Drupal with its HttpKernel component. We'll look at the component itself and how Drupal uses it to coordinate the request/response cycle.
We've got a lovely mix of announcements for you today: Drupal's latest minor release, 10.2.x is now available; a new major release schedule for Drupal was recently announced; ICYMI: videos added to 4 tutorials in our new Routes and Controllers in Drupal course; and our office is officially closed the week of December 25 through January 1.
James Shields (lostcarpark on Drupal.org) has once again rounded up fellow Drupal community members to write articles for a 2023 Drupal Advent Calendar, hosted on his personal site, lostcarpark.com. This year, Drupalize.Me trainers Amber Matz and Joe Shindelar contributed articles to the Advent Calendar. Amber's article on adding Help Topics to a module was published on December 17, and Joe's in-depth overview of Drupal's upcoming switch from annotations to native PHP attributes was published on December 21. Check out the Drupal Advent Calendar project (link inside) for more interesting and informative articles.
What If Yoda Taught You Drupal?
Blog postEarlier this quarter, our team got together in Boise, Idaho for our annual retreat. These retreats are always a great opportunity to reconnect, and also to talk about the future of our business. One of the things that's been coming up in a lot of our discussions is how we could leverage Artificial Intelligence (AI) to improve our product, customer service, and learning outcomes for our members. I think it's fair to say that no one on our team is an AI expert at this point, but we are all at least curious.
So, while we were having this discussion I did the only logical thing I could think of: I visited chat.openai.com and asked "How would Yoda go about helping me learn Drupal 10?"
We've added 3 videos to tutorials in our recently published Routes and Controllers in Drupal course. Lead trainer, Joe Shindelar, walks through essential concepts and skills for Drupal module developers like creating a route with a controller, understanding how parameters and upcasting work in Drupal, and how to use route parameters in a practical example with a route definition and a custom page controller class.
Years ago I was involved with authoring the Drupal User Guide, and I’m still the maintainer today. Now, we want to pick up where the Drupal User Guide left off, and create a Drupal Module Developer Guide. This hands-on module developer guide will build on the site and the guiding scenario used for the User Guide. We’ll walk through the process of authoring a couple of custom modules to meet your client’s needs and in the process, learn the basics of Drupal module development through writing “real-world” code.
Drupalize.Me trainer Joe Shindelar has recorded a new video walk-through of how he goes about finding out what type of plugin you want to add, and how to find out what code is expected, and where to put that code in your module. The video is now embedded in the written version of the tutorial, Implement a Plugin of Any Type, available to our members.
On the Drupalize.Me team, we're fans of using DDEV to install Drupal locally. We use DDEV for development work on the site, tutorial demo sites, and workshops. While the Drupal community is spoiled for choice when it comes to options for local development, we've chosen DDEV for a lot of reasons (which we'll get into in this tutorial), but mostly because we use it every day and it works great.
Earlier this month I hosted a Drupal-to-Drupal Migration Workshop, and one of the attendees asked about merging two entity reference fields into a single field during the migration. I wasn't sure how to approach this but we brainstormed some pseudo code, and then came up with two solutions.
Installing Drupal using the instructions in this tutorial will give you a working Drupal site that can be used for learning, or real-world project development.
Before you can work on a Drupal site locally (on your computer), you'll need to set up a local development environment. This includes all the system requirements like PHP and a web server, that Drupal needs in order to run. Our favorite way to accomplish this is using DDEV.
In this tutorial we'll learn:
- How to install and configure DDEV for use with a Drupal project.
- How to use DDEV's integrated Composer to download Drupal and Drush.
- How to install Drupal inside DDEV so you can access the site and start doing development.
By the end of this tutorial, you should be able to set up a local development environment for learning Drupal or working on a new Drupal project.
By default, individual forms in Drupal are not output using Twig template files. It's possible to associate a form with a Twig template file by creating a new theme hook, and then referencing that theme hook from the $form
array that defines the form. Doing so allows theme developers to customize the layout of the elements in the form using HTML and CSS.
This is useful when you want to change the layout of the entire form. For example, putting the elements into 2 columns. If you want to change individual elements in the form, you can often do so by overriding element specific Twig template files.
In this tutorial, we'll:
- Learn how to create a new theme hook that can be used to theme an element in a render array.
- Associate the
$form
we want to theme with the new theme hook we created. - Create a Twig template file for the theme hook that will allow us to lay out the form elements using custom HTML.
By the end of this tutorial, you should be able to associate a Twig template file with any form in Drupal, so that you can customize its layout using HTML and CSS.
Do you know some PHP and want to learn how to create a custom page at a custom URL in Drupal? You're in the right place.
Every web framework has the same job: provide a way for developers to map user-accessible URLs with code that builds the page. Routes, controllers, and responses are what module developers use to create pages at custom URLs in a Drupal site.
In this tutorial, we'll:
- Define what routes, controllers, and responses are.
- Explain the routing workflow that Drupal uses to match a URL to a route.
- Define routing system-related terms like parameter and upcasting.
By the end of this tutorial, you should be able to explain how a developer uses routes, controllers, and responses to create custom pages in a module.