-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate usage of ob_* functions in favor of yielding #3950
Conversation
d7691f7
to
f4201ff
Compare
This PR was merged into the 3.x branch. Discussion ---------- Abstract node capture in its own Node To prepare the work for #3950, I'd like to abstract the usage of `echo` into a single node that can be reused by other nodes. The cache node is a good example of defining something that is more semantic are reusable as well. The node itself now just generates the wrapper that can then be returned, echoed, yielded, ... Commits ------- 6ebbc30 Abstract node capture in its own Node
FYI, I have run Symfony tests against this branch and did not spot any failures. |
(all green with TwigComponent / LiveComponent) |
69f20a6
to
e44c77d
Compare
Thank you for testing! |
Hi @fabpot! Is it possible to update PR description with the motivation and pros of this change? ob_* functions and yielding are niche enough (the former especially) that it would help to understand this change for not so advanced developers. |
@javaDeveloperKid the usage of output buffers makes Twig incompatible with code using Fibers for instance, because suspending a fiber to resume another one does not change the active output buffer. |
@stof Thank you. I really appreciate you are always willing to answer questions and share your knowledge. Even questions that are not addressed to you. |
@javaDeveloperKid intuitively, both architectures are probably using a similar amount of memory: we still need memory holding the whole generated output. |
Being able to use I would add that using As we don't release major releases that often, that's always a good occasion to modernize the code. |
This change allows to use asynchronous functions in twig templates. I built a small demo app with ReactPHP and Twig: https://gist.github.com/GromNaN/37e661f2ff06735d8b93ff93b24f8257 |
@GromNaN Ok, so it's a framework designed for asynchronous PHP coding that can leverage changes from this PR. I thought that Twig itself will have some parts working asynchronously somehow. |
…rue` for now) (smnandre) This PR was squashed before being merged into the 2.x branch. Discussion ---------- [Twig][Live] Skip Twig 3.9 🚒 (do not set `use_yield = true` for now) As Symfony Twig Bridge & Twig Bundle have decided to skip Twig 3.9 for now, we should do the same, as testing and/or maintaining a compatible version would be really hard without the bundle support. symfony/twig-bridge@2abddb1 symfony/twig-bundle@23a02ff Update: Twig 3.9 introduce a major change in the way templates are rendered, and to fully test/fix our compatibility, we need to wait Bridge and Bundle to allow Twig 3.9 In the meantime, please do not set "use_yield = true" as we are not ready yet. This is something that has a major impact on TwigComponent and LiveComponent, and we'll probably need some changes on the CI / test suite to handle both modes. --- Pull Request (compatibility - wip) : #1487 (help welcomed) Issue: #1390 Twig PR : twigphp/Twig#3950 Commits ------- 6165384 [Twig][Live] Skip Twig 3.9 🚒 (do not set `use_yield = true` for now)
…rue` for now) (smnandre) This PR was squashed before being merged into the 2.x branch. Discussion ---------- [Twig][Live] Skip Twig 3.9 🚒 (do not set `use_yield = true` for now) As Symfony Twig Bridge & Twig Bundle have decided to skip Twig 3.9 for now, we should do the same, as testing and/or maintaining a compatible version would be really hard without the bundle support. symfony/twig-bridge@2abddb1 symfony/twig-bundle@23a02ff Update: Twig 3.9 introduce a major change in the way templates are rendered, and to fully test/fix our compatibility, we need to wait Bridge and Bundle to allow Twig 3.9 In the meantime, please do not set "use_yield = true" as we are not ready yet. This is something that has a major impact on TwigComponent and LiveComponent, and we'll probably need some changes on the CI / test suite to handle both modes. --- Pull Request (compatibility - wip) : symfony/ux#1487 (help welcomed) Issue: symfony/ux#1390 Twig PR : twigphp/Twig#3950 Commits ------- 61653842 [Twig][Live] Skip Twig 3.9 🚒 (do not set `use_yield = true` for now)
No description provided.