openeuropa / ecl-twig-loader
Europa Component Library Twig loader.
Installs: 140 542
Dependents: 5
Suggesters: 0
Security: 0
Stars: 1
Watchers: 20
Forks: 2
Open Issues: 2
Requires
- php: >=8.0
- twig/twig: ^2.14.7 || ^3.4.3
Requires (Dev)
- openeuropa/code-review: ^2.0.0-alpha6
- phpunit/phpunit: ^9
This package is auto-updated.
Last update: 2024-10-20 13:07:49 UTC
README
Twig loader for Europa Component Library Version 3, it allows to load components by accessing them via a configurable namespace.
For example, given you have the following ECL components:
/path/to/components/
├── twig-component-link
│ └── ecl-link.html.twig
└── twig-component-language-list
├── ecl-language-list.html.twig
├── ecl-language-list-grid.html.twig
└── ecl-language-list-item.html.twig
If you set up the loader as follows:
<?php use \OpenEuropa\Twig\Loader\EuropaComponentLibraryLoader; $loader = new EuropaComponentLibraryLoader(['ecl'], '/components', '/path/to'); $twig = new Twig_Environment($loader);
Then you can load the link component in the following way:
{% include '@ecl/link/link.html.twig' with { link: { type: 'standalone', label: 'Standalone link' } } %}
You can also use a shorter form, based on implicit naming conventions:
{% include '@ecl/link' with { link: { type: 'standalone', label: 'Standalone link' } } %}
To load sub-components append them after the component name:
{% include '@ecl/language-list/language-list-item' %}
Installation using Docker Compose
The setup procedure can be simplified by using Docker Compose.
Requirements:
Copy docker-compose.yml.dist into docker-compose.yml.
You can make any alterations you need for your local Docker setup. However, the defaults should be enough to set the project up.
Run:
$ docker-compose up -d
Then:
$ docker-compose exec web composer install
Step debugging
To enable step debugging from the command line, pass the XDEBUG_SESSION
environment variable with any value to
the container:
docker-compose exec -e XDEBUG_SESSION=1 web <your command>
Please note that, starting from XDebug 3, a connection error message will be outputted in the console if the variable is set but your client is not listening for debugging connections. The error message will cause false negatives for PHPUnit tests.
To initiate step debugging from the browser, set the correct cookie using a browser extension or a bookmarklet like the ones generated at https://www.jetbrains.com/phpstorm/marklets/.