一键导入
drupal-debugging
Drupal debugging techniques — Devel module, Drush watchdog, Twig debug, XDebug, error logging, and common troubleshooting patterns.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Drupal debugging techniques — Devel module, Drush watchdog, Twig debug, XDebug, error logging, and common troubleshooting patterns.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | drupal-debugging |
| description | Drupal debugging techniques — Devel module, Drush watchdog, Twig debug, XDebug, error logging, and common troubleshooting patterns. |
# Watch all errors
ddev drush ws --severity=error
# Last 20 entries
ddev drush ws --severity=error --count=20
# Watch all log levels
ddev drush ws --count=50
# Specific type
ddev drush ws --type=php --count=20
# Run PHP in Drupal context
ddev drush php:eval "var_dump(\Drupal::config('my_module.settings')->getRawData());"
# Check if service exists
ddev drush php:eval "var_dump(\Drupal::hasService('my_module.my_service'));"
# Check class autoloading
ddev drush php:eval "class_exists('Drupal\my_module\Service\MyService') ? print 'Found' : print 'Not found';"
# Inspect an entity
ddev drush php:eval "
\$node = \Drupal::entityTypeManager()->getStorage('node')->load(1);
print_r(\$node->toArray());
"
Enable in sites/default/services.yml:
parameters:
twig.config:
debug: true
auto_reload: true
cache: false
Then in templates:
{{ dump(content) }}
{{ dump(node) }}
{{ dump(_context|keys) }}
HTML comments in source will show template suggestions:
<!-- FILE NAME SUGGESTIONS:
* node--1--full.html.twig
* node--1.html.twig
* node--article--full.html.twig
x node--article.html.twig ← currently used
* node--full.html.twig
* node.html.twig
-->
# Install devel
composer require drupal/devel
ddev drush en devel -y
In PHP:
// Dump and die
dpm($variable); // Krumo output in message area
ksm($variable); // Krumo output (devel module)
dvm($variable); // Var dump
// Krumo (in Twig via Devel)
// {{ devel_dump(node) }}
# Clear all caches
ddev drush cr
# Rebuild theme registry only
ddev drush php:eval "\Drupal::service('theme.registry')->reset();"
# Check cache hit for a page (Drupal page cache)
# Look for X-Drupal-Cache: HIT in response headers
curl -I https://my-project.ddev.site/
# Check Big Pipe and render cache
ddev drush state:get drupal.maintenance_mode
# List all services matching a pattern
ddev drush devel:services | grep my_module
# List all services
ddev drush devel:services
# Check container definition
ddev drush php:eval "
\$def = \Drupal::getContainer()->getDefinition('my_module.my_service');
var_dump(\$def);
"
# List all enabled modules
ddev drush pm:list --status=enabled
# Check which modules implement a hook
ddev drush php:eval "
\$modules = \Drupal::moduleHandler()->getImplementations('form_alter');
print implode(', ', \$modules);
"
# Check module info
ddev drush pm:info my_module
| Problem | Solution |
|---|---|
| Class not found | Check namespace, PSR-4 in .info.yml, run composer dump-autoload |
| Service not found | Check services.yml syntax, run ddev drush cr |
| Template not used | Enable Twig debug, check template suggestions in HTML comments |
| Hook not firing | Check class is registered in services.yml, verify Hook attribute |
| Config not saving | Check config schema exists in config/schema/ |
| Migration failing | ddev drush ws for details, check field mappings |
# Enable XDebug
ddev xdebug on
# Disable XDebug (performance)
ddev xdebug off
# Check XDebug status
ddev xdebug status
Configure IDE (PHPStorm) to listen on port 9003.
HTMX in Drupal 11.3+ core — the Htmx PHP fluent builder, dynamic forms with swapOob, partial routes with _htmx_route, response headers, and Drupal.behaviors integration. Use when building interactive UI without full-page reloads using Drupal's native HTMX support.
DDEV local development expertise. Use when working with DDEV projects, containers, configuration, or troubleshooting DDEV environments.
Custom Docker Compose local development patterns. Use when working with Docker-based local environments, container configuration, or troubleshooting Docker setups.
Drupal access control — permissions.yml, access callbacks, AccessResult, custom access checkers, and entity access.
Drupal Cache API — cache tags, contexts, max-age, cache bins, invalidation, and adding cache metadata to render arrays.
Drupal Composer management — requiring modules, updates, patches via composer-patches, and version constraints.