@@ -11,8 +11,8 @@ to familiarize yourself in the `TwigComponent documentation`_.
11
11
12
12
A real-time product search component might look like this::
13
13
14
- // src/Components/ProductSearch.php
15
- namespace App\Components;
14
+ // src/Twig/ Components/ProductSearch.php
15
+ namespace App\Twig\ Components;
16
16
17
17
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
18
18
use Symfony\UX\LiveComponent\Attribute\LiveProp;
@@ -113,8 +113,8 @@ documentation to get the basics of Twig components.
113
113
114
114
Suppose you've already built a basic Twig component::
115
115
116
- // src/Components/RandomNumber.php
117
- namespace App\Components;
116
+ // src/Twig/ Components/RandomNumber.php
117
+ namespace App\Twig\ Components;
118
118
119
119
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;
120
120
@@ -141,7 +141,7 @@ re-rendered live on the frontend), replace the component's
141
141
142
142
.. code-block :: diff
143
143
144
- // src/Components/RandomNumber.php
144
+ // src/Twig/ Components/RandomNumber.php
145
145
- use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;
146
146
+ use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
147
147
+ use Symfony\UX\LiveComponent\DefaultActionTrait;
@@ -194,8 +194,8 @@ LiveProps: Stateful Component Properties
194
194
195
195
Let's make our component more flexible by adding a ``$max `` property::
196
196
197
- // src/Components/RandomNumber.php
198
- namespace App\Components;
197
+ // src/Twig/ Components/RandomNumber.php
198
+ namespace App\Twig\ Components;
199
199
200
200
// ...
201
201
use Symfony\UX\LiveComponent\Attribute\LiveProp;
@@ -294,7 +294,7 @@ Well, actually, we're missing one step. By default, a ``LiveProp`` is
294
294
295
295
.. code-block :: diff
296
296
297
- // src/Components/RandomNumber.php
297
+ // src/Twig/ Components/RandomNumber.php
298
298
// ...
299
299
300
300
class RandomNumber
@@ -1051,8 +1051,8 @@ that, when clicked, sets the min/max numbers back to a default value.
1051
1051
First, add a method with a ``LiveAction `` attribute above it that does
1052
1052
the work::
1053
1053
1054
- // src/Components/RandomNumber.php
1055
- namespace App\Components;
1054
+ // src/Twig/ Components/RandomNumber.php
1055
+ namespace App\Twig\ Components;
1056
1056
1057
1057
// ...
1058
1058
use Symfony\UX\LiveComponent\Attribute\LiveAction;
@@ -1115,8 +1115,8 @@ normal controller method that you would create with a route.
1115
1115
1116
1116
This means that, for example, you can use action autowiring::
1117
1117
1118
- // src/Components/RandomNumber.php
1119
- namespace App\Components;
1118
+ // src/Twig/ Components/RandomNumber.php
1119
+ namespace App\Twig\ Components;
1120
1120
1121
1121
// ...
1122
1122
use Psr\Log\LoggerInterface;
@@ -1162,8 +1162,8 @@ You can also pass arguments to your action by adding each as a
1162
1162
In your component, to allow each argument to be passed, add
1163
1163
the ``#[LiveArg()] `` attribute::
1164
1164
1165
- // src/Components/ItemList.php
1166
- namespace App\Components;
1165
+ // src/Twig/ Components/ItemList.php
1166
+ namespace App\Twig\ Components;
1167
1167
1168
1168
// ...
1169
1169
use Psr\Log\LoggerInterface;
@@ -1215,8 +1215,8 @@ Sometimes, you may want to redirect after an action is executed
1215
1215
page). You can do that by returning a ``RedirectResponse `` from your
1216
1216
action::
1217
1217
1218
- // src/Components/RandomNumber.php
1219
- namespace App\Components;
1218
+ // src/Twig/ Components/RandomNumber.php
1219
+ namespace App\Twig\ Components;
1220
1220
1221
1221
// ...
1222
1222
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@@ -1284,8 +1284,8 @@ You can also specify a modifier parameter to choose which files should be upload
1284
1284
1285
1285
The files will be available in a regular ``$request->files `` files bag::
1286
1286
1287
- // src/Components/FileUpload.php
1288
- namespace App\Components;
1287
+ // src/Twig/ Components/FileUpload.php
1288
+ namespace App\Twig\ Components;
1289
1289
1290
1290
use Symfony\Component\HttpFoundation\Request;
1291
1291
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
@@ -2474,8 +2474,8 @@ Changing the URL when a LiveProp changes
2474
2474
2475
2475
If you want the URL to update when a ``LiveProp `` changes, you can do that with the ``url `` option::
2476
2476
2477
- // src/Components/SearchModule.php
2478
- namespace App\Components;
2477
+ // src/Twig/ Components/SearchModule.php
2478
+ namespace App\Twig\ Components;
2479
2479
2480
2480
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
2481
2481
use Symfony\UX\LiveComponent\Attribute\LiveProp;
@@ -3488,7 +3488,7 @@ Then specify this new route on your component:
3488
3488
3489
3489
.. code-block :: diff
3490
3490
3491
- // src/Components/RandomNumber.php
3491
+ // src/Twig/ Components/RandomNumber.php
3492
3492
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
3493
3493
use Symfony\UX\LiveComponent\DefaultActionTrait;
3494
3494
@@ -3507,7 +3507,7 @@ You can also control the type of the generated URL:
3507
3507
3508
3508
.. code-block :: diff
3509
3509
3510
- // src/Components/RandomNumber.php
3510
+ // src/Twig/ Components/RandomNumber.php
3511
3511
+ use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
3512
3512
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
3513
3513
use Symfony\UX\LiveComponent\DefaultActionTrait;
0 commit comments