Part of the SDC ecosystem · 22 projects
This module offers development tools for Single-Directory Components, including validation for component definitions and templates via Drush or a web interface. It helps developers identify errors and best practices in their components.
SDC Devel checks your Single-Directory Components without rendering them.
It validates each component definition, then reads its Twig template for errors and bad practices.
A component stays a sandbox: portable, testable, and ready for a display builder.
Project status
1.1.0 is stable, for Drupal 10.3, 11 and 12. A development module: never install it on production.
What it checks
- Definition: on top of core's schema validation, such as a default outside its enum, or a required prop without a default.
- Template: parsed, never rendered. Calls to the Drupal application like
path()or|render, forbidden or deprecated filters, unused variables. - Display builder readiness:
attributeson a single root, schema defaults repeated in the template, simpler slot syntax.
Each message has a severity, from Notice to Critical, and a tip. See all the rules.
In the admin UI
Reports > UI components lists every component of the site with its messages, and opens the details of each one.
With Drush
Validate the components of a module or a theme, even one not installed yet with --install:
$ vendor/bin/drush sdcv --install my_theme
[notice] Start validation of my_theme...
-----------------
Component Severity Message
-----------------
local-tasks Warning Deprecated Twig filter: `spaceless`. The spaceless filter is deprecated as o
page Warning Use slots instead of hard embedding a component in the template with `embed`
form-element-label Error Unknown variable: `title_display`.
form-element-label Notice Print `attributes` on the single root element, or Display Builder wraps th
dropdown-menu Error Array of empty object.
dropdown-menu Warning `is iterable` test is too ambiguous. Use `is sequence` or `is mapping`.
In your CI
Extend the kernel test base, and your test fails when a component raises a Warning or worse:
use Drupal\Tests\sdc_devel\Kernel\SdcDevelComponentKernelTestBase;
use PHPUnit\Framework\Attributes\CoversNothing;
#[CoversNothing]
final class ComponentValidatorTest extends SdcDevelComponentKernelTestBase {
protected static $modules = ['my_module_with_components'];
protected static $themes = ['my_theme_with_components'];
}
The severities, providers and components it reports are configurable, see the usage documentation.
Installation
composer require --dev drupal/sdc_devel
drush en sdc_devel
UI Suite
SDC Devel was ui_patterns_devel, part of UI Patterns 2. It works on its own, and shines with the other UI Suite modules and Display Builder.
Similar projects
Component Libraries: Devel also validates component definitions, focused on JSON schema.
Support
Support my open source work on Liberapay. Need a feature, a fix or help on your project? I take sponsored work and freelance missions: contact me.
Ask your assistant about SDC Devel
Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works
Depends on
Dependencies of the latest stable release
No dependencies recorded for this project.
Required by
Tracked projects that depend on this one
No tracked projects depend on this one yet.