Reputation: 21
I get an error in my services.yml : services.yml does not contain valid YAML Symfony 3
redirectionListener:
class: Gba\GbaBundle\Listener\RedirectionListener
arguments: [@service_container, @session]
tags:
- { name: kernel.event_listener, event: kernel.request, method: onKernelRequest }
Can you help me
Thanks
Screenshot:
Upvotes: 1
Views: 12704
Reputation: 1639
In my case it was due to having blanks at the end of the line after the } symbol.
Upvotes: 0
Reputation: 1
I had this error once. It was because I didn't let a blank line at the end of my services.yaml file. Once I did so, no more errors !
Upvotes: 0
Reputation: 17166
There are some restrictions in yaml you have to be aware of. Symfony has a neat command line tool you can use to check if a yaml file is valid that will also try to point you to where the error lies. You can run it like this:
bin/console yaml:lint src/Gba/GbaBundle/Resources/config/services.yml
This will only do the lint on this one file you can also point it to a whole directory of files if you want.
My best guess is, that you have to put quotes around the services defined as arguments and in fact I prefer to quote every string value in yaml:
redirectionListener:
class: 'Gba\GbaBundle\Listener\RedirectionListener'
arguments: ['@service_container', '@session']
tags:
- { name: 'kernel.event_listener', event: 'kernel.request', method: 'onKernelRequest' }
Other things to look out for in yaml is correct indentation and mixing spaces & tabs.
Upvotes: 5