Skip to content

Commit db6f98d

Browse files
committed
Add Symfony integration explanation
1 parent 52b022f commit db6f98d

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,30 @@ $twig->addExtension(new \Squirrel\TwigPhpSyntax\PhpSyntaxExtension());
2222

2323
You can also have a look at the extension definition and create your own extension class to only include some of the features, if you do not like all of them.
2424

25+
### Symfony integration
26+
27+
If you use `autoconfigure` (which is the default) you just need to load the PhpSyntaxExtension class in `services.yaml` in the `config` directory of your project (the first four lines should already be there, just add the line with the PhpSyntaxExtension class at the end of the file):
28+
29+
```yaml
30+
services:
31+
_defaults:
32+
autowire: true
33+
autoconfigure: true
34+
35+
# Just add the following line, Symfony will register
36+
# the extension in Twig for you if Twig is installed
37+
Squirrel\TwigPhpSyntax\PhpSyntaxExtension: ~
38+
```
39+
40+
If you do not use `autoconfigure`, you can add the twig extension tag to the service definition:
41+
42+
```yaml
43+
services:
44+
Squirrel\TwigPhpSyntax\PhpSyntaxExtension:
45+
tags:
46+
- { name: twig.extension }
47+
```
48+
2549
Features
2650
--------
2751

0 commit comments

Comments
 (0)