PIRLS - Drupal's Core .yml files
Week 2Research

PIRLS - Drupal's Core .yml files

Learn about Drupal's core .yml files, including info, routing, and services, explained simply using a restaurant analogy to help you understand module configuration.

Wednesday, June 3, 2026
#drupal#yaml#web development#drupal modules#backend development

If you have opened some repository, chances are that you have worked on some of them! Now they are a lot, let us learn them in a simple way one by one.

Say you are a restraunt owner, starting you the amazing food chain called - "More Food, Less Money". You attract a lot of hungry customers who want quality food. So to start and scale up, you have to do the following things

  1. Get your Business License.

  2. Decide on the Host & Menu.

  3. Bing new staff & Kitchen Appliances

  4. Set up good Decor & Ambiance. Ik you love an asthetic place ;)

  5. Establish for a keycard system for security.

Here let's call it ai_chef the module

The Business Liscence - [module].info.yml

Before you can open, you need a license. This tells the city (Drupal) your restaurant's name, its description, and what basic utilities (dependencies) it requires to function. Without this, the city doesn't even know your restaurant exists.

yaml
name: 'AI Vegetarian Recipe Generator'
type: module
description: 'Integrates with the Gemini API to generate custom vegetarian recipes.'
core_version_requirement: ^10 || ^11
package: Custom AI
dependencies:
  - drupal:key

The Host & Menu - [module].routing.yml

When a customer asks for a table or a specific dish (a URL request like /about-us), the host uses this file to direct them to the exact right table or kitchen station (the PHP Controller) that will serve them.

yaml
ai_chef.menu_generator:
  path: '/admin/kitchen/generate-recipe'
  defaults:
    _controller: '\Drupal\ai_chef\Controller\RecipeController::buildMenu'
    _title: 'Generate New Recipes'
  requirements:
    _permission: 'generate veg recipes'

The Kitchen Staff & Appliances - [module].services.yml

You don't buy a new oven every time someone orders a pizza. This file registers your heavy-duty, reusable tools (PHP classes) and connects them to the main power grid (Dependency Injection). It ensures your module can efficiently share resources with the rest of Drupal.

yaml
services:
  ai_chef.gemini_service:
    class: Drupal\ai_chef\Service\GeminiRecipeService
    arguments: ['@http_client', '@config.factory']

The Decor & Ambiance - [module].libraries.yml

This manages your paint colors, lighting, and music (CSS and JavaScript). You don't want to pay for a mariachi band in the quiet dining room; this file lets you define groups of styles/scripts and load them only on the specific pages that need them.

yaml
kitchen_ambiance:
  version: 1.0
  css:
    theme:
      css/restaurant-theme.css: {}
  js:
    js/gemini-integration.js: {}
  dependencies:
    - core/drupal
    - core/jquery

The Keycard System - [module].permissions.yml

This dictates security. It defines the specific digital locks on your doors (e.g., "Access the VIP lounge" or "Edit the main menu") so the site administrator can hand out the right keycards to specific staff roles.

yaml
generate veg recipes:
  title: 'Generate Vegetarian Recipes'
  description: 'Allows staff to use the Gemini API to create new menu items.'
  restrict access: true

A cool way to remember this?

You struggle to remember all these things as this is a lot of juggling for you, :(

But don't worry, your best friend suggests you something to help you:

To remember the five main .yml files, think of stringing together a necklace of PIRLS (Pearls).

P - Permissions ([module].permissions.yml)

I - Info ([module].info.yml)

R - Routing ([module].routing.yml)

L - Libraries ([module].libraries.yml)

S - Services ([module].services.yml)

Blog image
HD

Hrishikesh Dalal

Full-stack developer passionate about open-source software, web technologies, and building products that matter. Currently exploring Drupal ecosystem through Google Summer of Code. Interested in PHP, JavaScript, and system design.