diff --git a/highlight_php.module b/highlight_php.module
index c650c87..f2bcfb7 100644
--- a/highlight_php.module
+++ b/highlight_php.module
@@ -5,6 +5,8 @@
  * Shared functions and hooks for the highlight_php module.
  */
 
+use Drupal\Core\Hook\Attribute\LegacyHook;
+use Drupal\highlight_php\Hook\HighlightPhpHooks;
 use Drupal\Component\Utility\Html;
 use Drupal\Core\Routing\RouteMatchInterface;
 use Highlight\Highlighter;
@@ -12,12 +14,9 @@ use Highlight\Highlighter;
 /**
  * Implements hook_help().
  */
+#[LegacyHook]
 function highlight_php_help($route_name, RouteMatchInterface $route_match) {
-  if ($route_name === 'help.page.highlight_php') {
-    $text = file_get_contents(__DIR__ . '/README.md');
-    return '<pre>' . Html::escape($text) . '</pre>';
-  }
-  return '';
+  return \Drupal::service(HighlightPhpHooks::class)->help($route_name, $route_match);
 }
 
 /**
diff --git a/highlight_php.services.yml b/highlight_php.services.yml
index 3caa2fc..3415b6c 100644
--- a/highlight_php.services.yml
+++ b/highlight_php.services.yml
@@ -4,3 +4,7 @@ services:
     arguments: ['@renderer']
     tags:
       - { name: twig.extension, priority: 1 }
+
+  Drupal\highlight_php\Hook\HighlightPhpHooks:
+    class: Drupal\highlight_php\Hook\HighlightPhpHooks
+    autowire: true
diff --git a/src/Hook/HighlightPhpHooks.php b/src/Hook/HighlightPhpHooks.php
new file mode 100644
index 0000000..73c24d9
--- /dev/null
+++ b/src/Hook/HighlightPhpHooks.php
@@ -0,0 +1,26 @@
+<?php
+
+namespace Drupal\highlight_php\Hook;
+
+use Drupal\Component\Utility\Html;
+use Drupal\Core\Routing\RouteMatchInterface;
+use Drupal\Core\Hook\Attribute\Hook;
+
+/**
+ * Hook implementations for highlight_php.
+ */
+class HighlightPhpHooks {
+
+  /**
+   * Implements hook_help().
+   */
+  #[Hook('help')]
+  public function help($route_name, RouteMatchInterface $route_match) {
+    if ($route_name === 'help.page.highlight_php') {
+      $text = file_get_contents(__DIR__ . '/README.md');
+      return '<pre>' . Html::escape($text) . '</pre>';
+    }
+    return '';
+  }
+
+}
