symfony / ux

Symfony UX initiative: a JavaScript ecosystem for Symfony
https://ux.symfony.com/
MIT License
824 stars 298 forks source link

[TwigComponent] Support HTTP render #707

Open onEXHovia opened 1 year ago

onEXHovia commented 1 year ago

TwigComponent is great as a replacement render(controller(...)). The page often consists of different blocks, and in order not to overload the controller, the page could be broken through render(controller (...)) but he causes performance issues CPU.

At the moment, the only difference is that the controller can be called on the URL. It is very common to need update a specific block after submitting form. What do you think about this?

weaverryan commented 1 year ago

I also think that TwigComponents is a great replacement for render(controller()) when you're not intending to cache the result (e.g. render_esi) for the performance reasons you suggested.

This is already possible today. What piece are you missing? You mentioned:

At the moment, the only difference is that the controller can be called on the URL. It is very common to need update a specific block after submitting form

Can you give me more info about the use-case? If you transform a TwigComponent to a LiveComponent, then you CAN "access" that component via a URL - you can get that URL by using the (undocumented) component_url function. I'm not sure your use-case, but you can get the URL in twig via:

{{ component_url('my_component_name, { prop1: 'foo'}) }}
onEXHovia commented 1 year ago

I also think that TwigComponents is a great replacement for render(controller()) when you're not intending to cache the result (e.g. render_esi) for the performance reasons you suggested.

Yes, you are right, but for setting esi you need cloudflare or varnish. Varnish in the base version does not have parallel execution capability. Sometimes support looks like a lot of work 🙃

Can you give me more info about the use-case? If you transform a TwigComponent to a LiveComponent, then you CAN "access" that component via a URL - you can get that URL by using the (undocumented) component_url function. I'm not sure your use-case, but you can get the URL in twig via:

We do not use LiveComponent, since need a solution only for the backend without js. TwigComponent looks like a good analogue https://github.com/viewcomponent/view_component

Perhaps it makes sense to move this feature to TwigComponent from LiveComponent.

carsonbot commented 5 months ago

Thank you for this issue. There has not been a lot of activity here for a while. Has this been resolved?

carsonbot commented 4 months ago

Friendly reminder that this issue exists. If I don't hear anything I'll close this.

carsonbot commented 4 months ago

Hey,

I didn't hear anything so I'm going to close it. Feel free to comment if this is still relevant, I can always reopen!