Skip to content

Instantly share code, notes, and snippets.

@anavdesign
Created January 25, 2019 01:28
Show Gist options
  • Save anavdesign/eb963060c8fa2a59f9fc5b963b228285 to your computer and use it in GitHub Desktop.
Save anavdesign/eb963060c8fa2a59f9fc5b963b228285 to your computer and use it in GitHub Desktop.
Drupal: Theme Local Settings

Drupal Local Theme Settings

Local Theme Development Setup

  1. Create Local Settings

    Copy and rename the sites/example.settings.local.php to be sites/default/settings.local.php

    sudo cp web/sites/example.settings.local.php web/sites/default/settings.local.php
    
  2. Disable Cache

    Uncomment these lines to Disable the Render and Page Cache:

    # Disable the render cache
    69 settings['cache']['bins']['render'] = 'cache.backend.null';
    
    # Disable Internal Page Cache
    91 settings['cache']['bins']['page'] = 'cache.backend.null';
    
    # Disable Dynamic Page Cache
    100 settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null';
    

Local Site Settings

  1. Site Settings

    Optional - Cleanup settings.php by removing all comments.

  2. Enable Local Settings

    Uncomment these lines in settings.php to include settings.local.php:

    if (file_exists(__DIR__ . '/settings.local.php')) {
      include __DIR__ . '/settings.local.php';
    }
    
  3. Local Site Database

    Move databse array to settings.local.php


Configuration Management Files Directory

Config files are saved in the sites/default/files/ directory

  1. Move the config files outside the site root directory

    sites/default/settings.php

    $config_directories['sync'] = '../config/sync';
    
  2. Delete config directory located in the /sites/default/files/ directory

    $rm -rf sites/default/files/config...
    
  3. Export the config files with drush

    $drush config-export
    

Disable Twig Cache

  1. Add Twig Config Parameters

    Open sites/development.services.yml and add the following block

    parameters:
      http.response.debug_cacheability_headers: true
      twig.config:
        debug: true
        auto_reload: true
        cache: false
    services:
      cache.backend.null:
        class: Drupal\Core\Cache\NullBackendFactory
    
  2. Rebuild Drupal Cache

    Rebuild the Drupal cache

    $drush cr
    

    or by visiting the following URL

    http://yoursite/core/rebuild.php
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment