Skip to content

Conversation

@FabienSalles
Copy link

@FabienSalles FabienSalles commented Oct 17, 2025

Q A
Bug fix? no
New feature? yes
Deprecations? no
Documentation? no
License MIT

In my project I don't use attributes like #[AsLiveComponent] in order to declare services and live components but I use yaml files (not my choice).
It works fine for all my services but live components are not well supported because we have to add extra parameters.

With #[AsLiveComponent] attribute, we have default values for :

  • the route metadata : 'ux_live_component'
  • and the url reference type metadata UrlGeneratorInterface::ABSOLUTE_PATH

We also add controller.service_arguments tag in LiveComponentExtension class.

But if we don't use this attribute and we want to use another type of service declaration, we have to add all these information :

services:
    MyServiceClass:
        tags:
            -
                name: twig.component
                live: true
                route: ux_live_component
                url_reference_type: 1
            -
                name: controller.service_arguments

If we do not, we have errors likes theses :

An exception has been thrown during the rendering of a template ("Symfony\Component\Routing\Router::generate(): Argument #1 ($name) must be of type string, null given, called in /app/vendor/symfony/ux-live-component/src/Util/LiveControllerAttributesCreator.php on line 63")
An exception has been thrown during the rendering of a template ("Symfony\Component\Routing\Router::generate(): Argument #3 ($referenceType) must be of type int, null given, called in /app/vendor/symfony/ux-live-component/src/Util/LiveControllerAttributesCreator.php on line 63")
The controller for URI "/_components/my_customer_live_component" is not callable: Controller "MyCustomLiveComponentClass" cannot be fetched from the container because it is private. Did you forget to tag the service with "controller.service_arguments"?

These errors do not exist for php attribute declaration so I made this PR to have the same behavior regardless of how the live component is declared

@carsonbot carsonbot added Feature New Feature LiveComponent Status: Needs Review Needs to be reviewed labels Oct 17, 2025
@FabienSalles FabienSalles force-pushed the feat/add-default-parameters-to-none-atttributes-declaration branch from b5dd556 to d6c45ba Compare October 17, 2025 16:31
@Kocal Kocal requested review from kbond and smnandre October 21, 2025 07:15
@Kocal
Copy link
Member

Kocal commented Dec 9, 2025

Hi,

For the same reasons explained in #3064, I'm 👎 here. The tag is purely internal and not documented, I don't think we want to encourage users to rely on it.

In my project I don't use attributes like #[AsLiveComponent] in order to declare services and live components but I use yaml files (not my choice).

Why? Because of "DDD"?

@Kocal Kocal added Status: Waiting feedback Needs feedback from the author and removed Status: Needs Review Needs to be reviewed labels Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature New Feature LiveComponent Status: Waiting feedback Needs feedback from the author

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants