Community best practices on how to prepare your local environment for Drupal development.

Optimize Drupal for Local Development

Debugging Twig templates

Enable debugging

You enable Twig Debugging in sites/default/services.yml.

Set the debug variable to true. And clear cache.

    debug: true 
  • If services.yml does not yet exist; copy to services.yml.
  • If Drupal has already been installed, permissions on the sites/default directory may need to be temporarily changed to allow write access.
  • How to change directory permissions
  • Once services.yml has been created and edited, change permissions back to lock down the sites/default directory.

To verify that Drupal is getting the twig.config parameter set as expected, run:

drush php:eval "var_export(\Drupal::getContainer()->getParameter('twig.config'));"


Disable Drupal (>=8.0) caching during development

Copy sites/example.settings.local.php to sites/default/settings.local.php

$ cp sites/example.settings.local.php sites/default/settings.local.php

Open settings.php file in sites/default and uncomment these lines:

if (file_exists($app_root . '/' . $site_path . '/settings.local.php')) {
  include $app_root . '/' . $site_path . '/settings.local.php';


The file is located under /sites.

Your final should look as follows (mind the indentation):

# Local development services.
# To activate this feature, follow the instructions at the top of the
# 'example.settings.local.php' file, which sits next to this file.
http.response.debug_cacheability_headers: true
    debug: true
    auto_reload: true
    cache: false
    class: Drupal\Core\Cache\NullBackendFactory    

Open settings.local.php and make sure is enabled.

$settings['container_yamls'][] = DRUPAL_ROOT . '/sites/';

Configure settings.local.php

Change the following to be TRUE if you want to work with enabled css- and js-aggregation:

$config['system.performance']['css']['preprocess'] = FALSE;
$config['system.performance']['js']['preprocess'] = FALSE;

Uncomment these lines to disable the render cache and disable dynamic page cache:

$settings['cache']['bins']['render'] = 'cache.backend.null';
$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null';

Add the following lines

$settings['cache']['bins']['page'] = 'cache.backend.null';

If you do not want to install test modules and themes, set the following to FALSE:

$settings['extension_discovery_scan_tests'] = FALSE;

Rebuild cache

Rebuild the Drupal cache otherwise your website will encounter an unexpected error on page reload. This can be done by with drush:

drush cr