drupal-services

Installation
SKILL.md

Drupal Services & Dependency Injection

Core Principle

Never use \Drupal::service() in classes — inject via constructor.

Dependency Injection Patterns

Controllers & Forms (ContainerInjectionInterface)

use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

final class MyController implements ContainerInjectionInterface {
  public function __construct(
    private readonly AccountProxyInterface $currentUser,
    private readonly EntityTypeManagerInterface $entityTypeManager,
  ) {}
Installs
31
GitHub Stars
71
First Seen
Apr 17, 2026
drupal-services — edutrul/drupal-ai