<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/new-in-twig-4-0-composing-blocks-at-runtime-symfony-blog--nypzdr5bw" -->

---
title: New in Twig 4.0: Composing Blocks at Runtime (Symfony Blog)
description: Twig 4.0 includes a BlockChain API for composing template blocks at runtime across independent themes, without requiring one template to extend another....
canonical: https://daily.dev/posts/new-in-twig-4-0-composing-blocks-at-runtime-symfony-blog--nypzdr5bw
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: New in Twig 4.0: Composing Blocks at Runtime (Symfony Blog) | daily.dev
og:description: Twig 4.0 includes a BlockChain API for composing template blocks at runtime across independent themes, without requiring one template to extend another....
og:url: https://daily.dev/posts/new-in-twig-4-0-composing-blocks-at-runtime-symfony-blog--nypzdr5bw
og:image: https://api.daily.dev/og/posts/NyPzDR5bw.png
og:image:alt: New in Twig 4.0: Composing Blocks at Runtime (Symfony Blog)
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# New in Twig 4.0: Composing Blocks at Runtime (Symfony Blog)

**[Symfony](https://daily.dev/sources/symfony)** · 3 min read · 4 upvotes · 0 comments

## Summary

Twig 4.0 includes a BlockChain API for composing template blocks at runtime across independent themes, without requiring one template to extend another. Available since Twig 3.29, it lets a chain of templates (or nested chains) resolve to the first matching block, enabling patterns like admin/application theme layering for form controls, CMS fields, and email fragments. Symfony's Twig Bridge already uses BlockChain internally to simplify form rendering, replacing manual block-map merging, and the post suggests other renderers like Ibexa Core, Prezent Grid, and Listing could adopt the same approach.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://symfony.com/blog/new-in-twig-4-0-composing-blocks-at-runtime>

## Questions this post answers

### How does Twig's BlockChain class let me combine blocks from unrelated templates at runtime?

BlockChain lets you create an ordered list of templates, loaded templates, or nested chains and render a named block from the first one that defines it, without any template extending another. For example, chaining admin_theme.html.twig, application_theme.html.twig, and a base_theme.html.twig default lets renderBlock('cell') resolve 'cell' from the admin theme while block('cell_value') inside it picks up the application theme's override.

_Developers layering CMS or form themes can follow Twig BlockChain updates like this on daily.dev._

### When was Twig's BlockChain feature for block composition first released?

BlockChain first shipped in Twig 3.29 and is also included in Twig 4.0, so it can be used in production immediately without waiting for the major version. Symfony's Twig Bridge already uses BlockChain when it is available, and projects upgrading to Twig 3.29 should update the Twig Bridge alongside it to get the integration.

_Teams planning a Twig upgrade can track version-specific changes like this via daily.dev._

### How did Symfony Forms combine blocks from different templates before BlockChain existed?

Before BlockChain, the Symfony Twig Bridge had to manually walk template parent hierarchies, merge block maps together, and pass those merged maps into Twig's internal rendering API to let a form_row block from one theme call block('form_widget') and find an override defined in a different theme. BlockChain replaces that manual traversal with a built-in runtime lookup mechanism.

_Anyone maintaining custom Twig renderers can weigh this kind of internal-API tradeoff on daily.dev._

## Similar posts on daily.dev

- [New in Twig 4.0: A First-Class Sandbox \(Symfony Blog\)](https://daily.dev/posts/new-in-twig-4-0-a-first-class-sandbox-symfony-blog--evipkpgid) · Symfony · 6 upvotes · 0 comments
- [Dynamically loading template parts in block themes](https://daily.dev/posts/dynamically-loading-template-parts-in-block-themes-gvwojm0f0) · WordPress Developer · 7 upvotes · 0 comments
- [Twig 3.28.0 released \(Symfony Blog\)](https://daily.dev/posts/twig-3-28-0-released-symfony-blog--dpjk2dnjm) · Symfony · 4 upvotes · 0 comments

---

Tags: [#php](https://daily.dev/tags/php), [#symfony](https://daily.dev/tags/symfony)

[View this post on daily.dev](https://daily.dev/posts/new-in-twig-4-0-composing-blocks-at-runtime-symfony-blog--nypzdr5bw)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"New in Twig 4.0: Composing Blocks at Runtime (Symfony Blog)","url":"https://daily.dev/posts/new-in-twig-4-0-composing-blocks-at-runtime-symfony-blog--nypzdr5bw","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/new-in-twig-4-0-composing-blocks-at-runtime-symfony-blog--nypzdr5bw"},"datePublished":"2026-09-25T10:24:29.522Z","dateModified":"2026-09-25T10:24:54.564Z","description":"Twig 4.0 includes a BlockChain API for composing template blocks at runtime across independent themes, without requiring one template to extend another....","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/327b244859fddae8f3a20d0225898aa0?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/327b244859fddae8f3a20d0225898aa0?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Symfony","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Symfony","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/cc07051b7112472f9729e73c14660a64","url":"https://daily.dev/sources/symfony"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/new-in-twig-4-0-composing-blocks-at-runtime-symfony-blog--nypzdr5bw","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":4},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"php,symfony","timeRequired":"PT3M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Symfony","item":"https://daily.dev/sources/symfony"},{"@type":"ListItem","position":3,"name":"New in Twig 4.0: Composing Blocks at Runtime (Symfony Blog)"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/new-in-twig-4-0-composing-blocks-at-runtime-symfony-blog--nypzdr5bw#faq","mainEntity":[{"@type":"Question","name":"How does Twig's BlockChain class let me combine blocks from unrelated templates at runtime?","acceptedAnswer":{"@type":"Answer","text":"BlockChain lets you create an ordered list of templates, loaded templates, or nested chains and render a named block from the first one that defines it, without any template extending another. For example, chaining admin_theme.html.twig, application_theme.html.twig, and a base_theme.html.twig default lets renderBlock('cell') resolve 'cell' from the admin theme while block('cell_value') inside it picks up the application theme's override. Developers layering CMS or form themes can follow Twig BlockChain updates like this on daily.dev."}},{"@type":"Question","name":"When was Twig's BlockChain feature for block composition first released?","acceptedAnswer":{"@type":"Answer","text":"BlockChain first shipped in Twig 3.29 and is also included in Twig 4.0, so it can be used in production immediately without waiting for the major version. Symfony's Twig Bridge already uses BlockChain when it is available, and projects upgrading to Twig 3.29 should update the Twig Bridge alongside it to get the integration. Teams planning a Twig upgrade can track version-specific changes like this via daily.dev."}},{"@type":"Question","name":"How did Symfony Forms combine blocks from different templates before BlockChain existed?","acceptedAnswer":{"@type":"Answer","text":"Before BlockChain, the Symfony Twig Bridge had to manually walk template parent hierarchies, merge block maps together, and pass those merged maps into Twig's internal rendering API to let a form_row block from one theme call block('form_widget') and find an override defined in a different theme. BlockChain replaces that manual traversal with a built-in runtime lookup mechanism. Anyone maintaining custom Twig renderers can weigh this kind of internal-API tradeoff on daily.dev."}}]}
```

