Skip to content

Commit 274dfb8

Browse files
committed
[LiveComponent] Add an information about live.component tag to the docs
1 parent 6d7051e commit 274dfb8

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

src/LiveComponent/doc/index.rst

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3561,6 +3561,59 @@ Debugging Components
35613561
Need to list or debug some component issues.
35623562
The `Twig Component debug command`_ can help you.
35633563

3564+
3565+
Registering Live Components manually
3566+
------------------------------------
3567+
3568+
.. versionadded:: 2.17
3569+
3570+
The ``live.component`` tag has been introduced in LiveComponents 2.17.
3571+
3572+
Sometimes you might need to register your Live Components manually. This can be useful if you want to provide a live component
3573+
along with a bundle. To do this, you can use the ``live.component`` tag:
3574+
3575+
.. configuration-block::
3576+
3577+
.. code-block:: yaml
3578+
3579+
services:
3580+
# ...
3581+
app.component.product_search:
3582+
class: App\Components\ProductSearch
3583+
# ...
3584+
tags:
3585+
- { name: 'live.component', key: 'ProductSearch', template: 'product_search.html.twig' }
3586+
3587+
.. code-block:: xml
3588+
3589+
<?xml version="1.0" encoding="UTF-8" ?>
3590+
<container xmlns="http://symfony.com/schema/dic/services"
3591+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3592+
xmlns:framework="http://symfony.com/schema/dic/symfony"
3593+
xsi:schemaLocation="http://symfony.com/schema/dic/services
3594+
https://symfony.com/schema/dic/services/services-1.0.xsd
3595+
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
3596+
3597+
<service id="app.component.product_search" class="App\Components\ProductSearch">
3598+
<!-- ... -->
3599+
<tag name="live.component" key="ProductSearch" template="product_search.html.twig" />
3600+
</service>
3601+
</container>
3602+
3603+
.. code-block:: php
3604+
3605+
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
3606+
3607+
return static function (ContainerConfigurator $container): void {
3608+
$services = $container->services();
3609+
$services
3610+
->set('app.component.product_search', App\Component\ProductSearch::class)
3611+
// ...
3612+
->tag('live.component', ['key' => 'product_search', 'template' => '@App/product_search.html.twig'])
3613+
;
3614+
};
3615+
3616+
35643617
Test Helper
35653618
-----------
35663619

0 commit comments

Comments
 (0)