04.
Yaml for Service Definitions
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
Whoops, an error! Please, try again later.
12 Comments
For me this is the most interesting course that you will not find anywhere else. Thanks guys, and please upgrade to symfony 4 if possible :D
Hey Helmi!
I love this course too :). It's on our list to update - but probably not until Symfony 5.
Cheers!
psst Symfony 5 is out ;)
Lol, so it goes! We HAVE released a deep dive into the HttpKernel for Symfony 5 - https://symfonycasts.com/sc... - but haven't gotten to this one yet!
Hi, how can we parse this yaml through java? If we parse the yaml file in java,will it call the java method
In that case I think you will need to find a yaml parser written in Java
Cheers!
There's an implied complexity where there is none: "The bummer of the calls key is that it has a funny syntax..."
As I understand YAML (see http://symfony.com/doc/curr..., the calls key could have the same syntax as that used by the arguments key, i.e.
calls:
- 'debug'
- ['Logger just got started!!!']
or vice-versa, arguments could be written as calls is
arguments: ['main', ['@logger.stream_handler']]
Feel free to correct me if I'm wrong
Hey Michael!
For a minute, I thought you were right - and I was excited because your way looks much easier to me! The problem is that there can be multiple calls, so the syntax would really look like this:
But in Symfony 2.7, there is a slightly shorter syntax http://symfony.com/blog/new-in-symfony-2-7-dependency-injection-improvements#improved-yaml-service-definition-syntax - it's still a bit complex, but better.
Cheers!
Ah, yes! I left out an array nesting. (I am going to stick with my original stance, however, that the syntax used for each could be the same, in terms of using dashes or brackets to indicate arrays) Readers/Viewers should still check out both of our links to the Symfony documents, so they are clear in understanding what the YAML is presenting.
Great series! Great site!
Is it me or it's not possible to refactor name for yaml services in phpstorm?
I'm using phpstorm 2016.2 and when I try to refactor and rename, it wont let me with an "error message" that has a thunderbolt and ''is not a valid identifier. I'm currently doing find all and replace.
Hi there!
I just tried it, and I *am* able to Refactor->Rename a YAML key (PhpStorm 2016.1 with activated Symfony plugin). However, it doesn't really work - I think it only has "YAML" intelligence - somehow maybe replacing other YAML keys that reference this (I'm not really sure). What I mean is: when I refactored the name of the service, it did *not* refactor my usage of that service from inside a controller.
So, I also find and replace to do this. It's why I like to make sure my service names are *just* long enough to be unique strings in my project. I also use "git grep service_name" to quickly find the usages.
In other words, afaik, you're not missing anything - I don't think it works sadly!
Awesome. Thanks for the quick reply!
"Houston: no signs of life"
Start the conversation!