Configure your development environment for Theming

One of the first things that I do when I start a new project is to configure my environment as development, to react on what I'm doing, specially when I'm theming. Disable cache, enable debug messages and more. These steps are among the ones that I always do:

Setting up my settings.local.php file

Go to the sites/ folder of your project and copy example.settings.local.php to the folder like this: cp example.settings.local.php default/settings.local.php (renaming it to settings.local.php in the process).

Open the file and locate this line: # $settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null';  Uncomment it (by removing the #). This will disable caching on your local development machine.

Open development.services.yml file and add these lines (be careful about indentations!):

parameters:
  twig.config:
    debug: true
    auto-reload: true
    cache: false

More configuration can be found in default.services.yml file. But don't edit that file, that won't work. Actually, in settings.php, the file services.yml is loaded (it doesn't exists, but it tries to load it), but by renaming default.services.yml into services.yml you are making global changes instead of development changes, and that's not a good practice. You always want to keep your development settings aside.

If everything is working correctly, you should have a lot of comments in your source (view source).

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.