File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,20 +5,24 @@ Symfony UX Twig Components for all HTML5 elements with ARIA support.
55## Installation
66
77``` bash
8- composer require html/ component-bundle
8+ composer require vardumper/html5-ux-twig- component-bundle
99```
1010
11+ The bundle includes automatic service registration - no additional configuration needed!
12+
1113## Configuration
1214
13- Register the bundle in ` config/bundles.php ` :
15+ The bundle is automatically registered via Symfony Flex. If you need to register it manually, add to ` config/bundles.php ` :
1416
1517``` php
1618return [
1719 // ...
18- Html\ComponentBundle\HtmlComponentBundle ::class => ['all' => true],
20+ Html\TwigComponentBundle\HtmlTwigComponentBundle ::class => ['all' => true],
1921];
2022```
2123
24+ All Twig Components are automatically discovered and registered through the bundle's DependencyInjection extension. No manual service configuration required!
25+
2226## Usage
2327
2428Use any HTML element as a Twig Component:
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Html \TwigComponentBundle \DependencyInjection ;
4+
5+ use Symfony \Component \Config \FileLocator ;
6+ use Symfony \Component \DependencyInjection \ContainerBuilder ;
7+ use Symfony \Component \DependencyInjection \Extension \Extension ;
8+ use Symfony \Component \DependencyInjection \Loader \PhpFileLoader ;
9+
10+ /**
11+ * HtmlTwigComponentExtension - Auto-registers Twig Components
12+ *
13+ * Automatically discovers and registers all Twig Component classes from the bundle,
14+ * enabling auto-configuration of components with #[AsTwigComponent] attribute.
15+ *
16+ * @author vardumper <info@erikpoehler.com>
17+ * @package Html\TwigComponentBundle\DependencyInjection
18+ */
19+ class HtmlTwigComponentExtension extends Extension
20+ {
21+ public function load (array $ configs , ContainerBuilder $ container ): void
22+ {
23+ $ loader = new PhpFileLoader (
24+ $ container ,
25+ new FileLocator (\dirname (__DIR__ ) . '/Resources/config ' )
26+ );
27+
28+ // Load services configuration
29+ $ loader ->load ('services.php ' );
30+ }
31+
32+ public function getAlias (): string
33+ {
34+ return 'html_twig_component ' ;
35+ }
36+ }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 55use Symfony \Component \HttpKernel \Bundle \Bundle ;
66
77/**
8- * HTML Component Bundle
8+ * HTML Twig Component Bundle
99 *
1010 * Provides Symfony UX Twig Components for all HTML5 elements with ARIA support.
1111 *
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Symfony \Component \DependencyInjection \Loader \Configurator ;
4+
5+ return static function (ContainerConfigurator $ configurator ): void {
6+ $ services = $ configurator ->services ()
7+ ->defaults ()
8+ ->autowire ()
9+ ->autoconfigure ();
10+
11+ // Auto-register all Twig Component classes
12+ $ services ->load ('Html \\TwigComponentBundle \\Twig \\' , '../../../Twig ' )
13+ ->tag ('controller.service_arguments ' );
14+ };
You can’t perform that action at this time.
0 commit comments