I've made a new set of REST APIs for a legacy monolith application and faced the same questions.
I will answer this question first:
How services and controllers should be separated in directories?
I went down the src/Service/{Something}/{Something}Manager.php
path as I thought that that was the way. As the project has grown, I regret that and will be moving to src/{Something}/Service/{Something}Manager.php
Why?
- I find the separation in namespacing much easier to read and much
harder to accidentally
use
the wrong class.
- I now have files split out across the application and it's much harder to abstract it into a library that can be re-used by other applications.
- I can't refactor functionality as easily - everything is spread out an
intertwined. If I were converting a monolith, I would prefer to have
code to refactor that was bound by some function so I could work on
that, before moving to the next.
There are other reasons but feel the need to separate this back out before the application gets any larger.
How services.yaml should look like? Well, the autowiring is amazing. I would keep your service yamls in the various functional splits (as above) and start refactoring them out. With the default autowiring config, you'll find that very little needs explicit definitions.
Where would you put UserAuthenticationProvider and/or WebSocketServer?
For the provider, probably something like, src/Security/Authentication/Provider/UserAuthenticationProvider.php
.
For the WS server, I'm not really sure - it depends where it sits in the app and how it's used.