// composer.json
{
"require": {
"php": ">=8.2",
"ext-ctype": "*",
"ext-iconv": "*",
"composer/package-versions-deprecated": "^1.11", // 1.11.99.1
"doctrine/annotations": "^1.0", // 1.12.1
"doctrine/doctrine-bundle": "^2", // 2.3.1
"doctrine/doctrine-migrations-bundle": "^3", // 3.1.1
"doctrine/orm": "^2", // 2.8.4
"knplabs/knp-time-bundle": "^1.15", // v1.16.0
"phpdocumentor/reflection-docblock": "^5.2", // 5.2.2
"sensio/framework-extra-bundle": "^6.0", // v6.1.2
"symfony/console": "5.2.*", // v5.2.6
"symfony/dotenv": "5.2.*", // v5.2.4
"symfony/flex": "^1.9", // v1.21.6
"symfony/form": "5.2.*", // v5.2.6
"symfony/framework-bundle": "5.2.*", // v5.2.6
"symfony/http-client": "5.2.*", // v5.2.6
"symfony/mailer": "5.2.*", // v5.2.6
"symfony/property-access": "5.2.*", // v5.2.4
"symfony/property-info": "5.2.*", // v5.2.4
"symfony/security-bundle": "5.2.*", // v5.2.6
"symfony/serializer": "5.2.*", // v5.2.4
"symfony/twig-bundle": "5.2.*", // v5.2.4
"symfony/validator": "5.2.*", // v5.2.6
"symfony/webpack-encore-bundle": "^1.6", // v1.11.1
"symfony/yaml": "5.2.*", // v5.2.5
"twig/cssinliner-extra": "^3.3", // v3.3.0
"twig/extra-bundle": "^2.12|^3.0", // v3.3.0
"twig/twig": "^2.12|^3.0" // v3.3.0
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.2", // 3.4.0
"fakerphp/faker": "^1.13", // v1.14.1
"symfony/debug-bundle": "^5.2", // v5.2.4
"symfony/maker-bundle": "^1.13", // v1.30.2
"symfony/monolog-bundle": "^3.0", // v3.7.0
"symfony/stopwatch": "^5.2", // v5.2.4
"symfony/var-dumper": "^5.2", // v5.2.6
"symfony/web-profiler-bundle": "^5.2" // v5.2.6
}
}
11 Comments
Hell there, nice tutorial, thanks. 😊
Question: as far as I know we can tag the interface in the services.yaml file as well, does it make any difference to do it in kernel.php?
Here is the code I like to use for tagging the interface:(sorry for indentation problem, can't type it here, idk why)
Hey alireza
That's a great question and you made me dug to be honest. If you tag your interface like that, the only downside is only the services defined in that
services.yamlfile will get benefit of it. If you have services defined in other file, or perhaps they come from a bundle, then your tag won't be automatically applied. It's likely that you won't be hit by this issue but it's the only difference I could find.Cheers!
Hey MolloKhan, thank you for the reply, good to know that. ;)
Hey! So, if I register an Interface as a service - it should be available as a service inside the whole application? I mean this is the main reason for registering services, isn't it?
For me it was interesting to see, that you can do this inside the kernel.php but I think there will be really no difference exept of having a way to create services and configure them before symfony does it.
Hey Michael B.
Yes, in this case, I think there should not be any difference unless a third party bundle implements your interface and then, in a different config file you register that service. In that situation, I think Symfony won't automatically tag such service but it's very unlikely to happen because third-party bundles do not depend on interfaces of your application, it's usually the other way around
Cheers!
In fact I was about to write the same question here :).
Great tuto so far. I love when I learn new things unrelated to the main topic in tutos (like this auto tag trick).
I had another question though, how we should do it in symfony 3.4, how we should inject all the services with specific interface to a service.
Hey Amin,
It should work this way: https://symfony.com/blog/ne... , you just need to tag them.
Cheers!
Thanks victor , I think it was cache problem, I had the same code, but wasn't work, but suddenly started to work. :)
Hey Amin,
Awesome! Then it was an easy fix ;) Yeah, my first rule in any weird case - clear the cache and see if it helped :)
Cheers!
"Houston: no signs of life"
Start the conversation!