December 2018

Disable cache and enable Twig Debug!

Disable cache and enable Twig Debug!

You will find this helps when developing drupal themes as it allows you to not have to clear cache everytime for you to see your change after you make a change to your theme.

1) copy $SITE_ROOT/sites/example.settings.local.php to $SITE_ROOT/sites/default/settings.local.php

2) edit settings.local.php

  1. a) uncomment:
    • $config['system.performance']['css']['preprocess'] = FALSE;
    • $config['system.performance']['js']['preprocess'] = FALSE;
    • $settings['cache']['bins']['render'] = 'cache.backend.null';
    • $settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null';
    • $settings['rebuild_access'] = TRUE;

3) edit $SITE_ROOT/sites/default/settings.php

  • a) uncomment:

 if (file_exists(__DIR__ . '/settings.local.php')) {
include __DIR__ . '/settings.local.php';

4) edit $SITE_ROOT/sites/  (under parameters:)

  • a) Add this code (this is a yml file so be sure to indent 2 spaces)

    debug: true
    auto_reload: true
    cache: false

You will probably get an error when you access the site after following this procedure.  
If you do, you will have to clear the cache. 

  1. using drush enter the command 'drush cr'
  2. using drupal console (you will have to research this as I have no experience with drupal console)
  3. if you do not have drush or drupal console you can clear the cache using rebuild.php
          http://<site name>/core/rebuild.php