Enabling Development and Debug Settings

Last updated on
21 February 2023

For releases of Patternkit using 9.1.0-beta5 or newer, developers have access to additional debug options. These must be enabled in a site's services.yml or development.services.yml file with the latter being the recommendation to avoid them being accidentally enabled on a Production environment.

Example service parameter configuration for debugging

parameters:
  # Configuration options to influence behavior of the Patternkit modules.
  patternkit.config:

    # This may be enabled to toggle debug features in the module.
    debug: true

    # Various operational features of the module may be toggled here.
    features:

      # Disable caching of pattern definitions for each request.
      bypass_pattern_cache: true

      # Ignore caching of patterns in database entities for blocks.
      bypass_database_cache: true

 Bypassing the Pattern Cache (bypass_pattern_cache)

Whenever patterns are discovered from the filesystem, the inventory of what patterns exist and where to find them is cached in the database. In most cases this is desirable to prevent unnecessary discovery operations only to find the same content, but when new patterns are under active development and being added or removed this may not be desirable. Enabling this option will disable this discovery caching and refresh the list of pattern library definitions and discovered patterns on every request.

If this work is happening less frequently, the performance hit for this option may be avoided by leaving it disabled and instead triggering a cache rebuild of the discovery cache or using the drush patternkit:cache:clear command to target it specifically.

Bypassing the Database Cache (bypass_database_cache)

When a pattern is used in a block, the data for that pattern is cached as an entity in the database to mitigate unintended breakage to existing content using a pattern. The content cached for each pattern when it is used includes:

  • The pattern's JSON schema
  • The pattern's Twig template content
  • The path to the pattern files
  • A hash of above content to easily identify when a change is detected
  • Additional metadata about the pattern

Whenever a pattern block is being rendered, the schema and twig template are loaded from this database entry instead of from the filesystem. In production usage, this adds stability to prevent changes to a pattern from unexpectedly impacting existing content until the affected block is manually updated. During the development of patterns, however, a template and schema may change frequently which makes this caching layer very frustrating since the block has to be manually updated after each change or a new block has to be created each time. The bypass_database_cache option resolves this by always loading the pattern data from the filesystem directly instead of from the cached database entry.

Help improve this page

Page status: No known problems

You can: