0

When I going to Disable Twig template cache , Fatal error . i.e

The website encountered an unexpected error. Please try again later. Error: Unsupported operand types in Drupal\Core\Template\TwigEnvironment->__construct() (line 69 of core\lib\Drupal\Core\Template\TwigEnvironment.php).

I followed below steps :

1.Copy and rename the file from sites/example.settings.local.php to sites/default/settings.local.php 2.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';
}

3.Uncomment these lines in settings.local.php

$settings['cache']['bins']['render'] = 'cache.backend.null';
$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null';
  1. Open development.services.yml in the sites folder and add the following code

     parameters:
    twig.config:
    debug: true
    auto_reload: true
    cache: false

  2. Rebuild the cache and your good to go

My development.services.yml code :

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

6
  • Are you sure the services.yml is still valid after you've edited it in point 4? Can you post the yml file?
    – 4uk4
    May 20, 2019 at 9:23
  • Yes services.yml file is inside sites\default my development.service.yml code 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
    – Arif
    May 20, 2019 at 9:46
  • services.yml file I have to write any things ?? I followed drupal.org/forum/support/theme-development/2016-05-21/…
    – Arif
    May 20, 2019 at 9:52
  • I meant the development.services.yml you've edited. Can you post the entire file?
    – 4uk4
    May 20, 2019 at 11:20
  • @Arif Are the whitespaces correct in your .yml file? I've added a comment in the original posting on drupal.org
    – Hudri
    May 20, 2019 at 12:24

1 Answer 1

2

The least hassle way is to install Drupal Console

Then run the command drupal site:mode dev (turns off caching and turns on twig debug)

Once you're done, run drupal site:mode prod (turns off twig debug, turns caching back on).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.