drupal-hook-patterns

Installation
SKILL.md

Drupal Hook Patterns

Always prefer OOP hooks with #[Hook] attribute in Drupal 11+. Never put business logic directly in .module files — use services. Always check existing hook implementations before adding new ones to avoid conflicts.

OOP Hooks (Drupal 11+)

Hook Attribute Pattern

declare(strict_types=1);

namespace Drupal\my_module\Hook;

use Drupal\Core\Hook\Attribute\Hook;
use Drupal\Core\StringTranslation\StringTranslationTrait;
Installs
39
GitHub Stars
18
First Seen
Jul 9, 2026