I’m building an app in Symfony2 that receives a HTML string via an API, does some work on it (think of something like the Tidy library, only with a different purpose) and then returns the fixed HTML.
The stuff that does all the work is mostly written in services, because they don’t need to return a Response object.
Where do I store those services? I’m putting them in bundles, but there’s no obvious place to store them. I understand that they can be stored anywhere, but I’m wondering what the default convention is.
If that code doesn’t have to be re-usable outside of Symfony2 projects, you can just put it into your bundle.
I’d go for something like:
Since it is a bundle, you can extract it to a separate package and re-use it for other Symfony2 projects.
If you want the code to be completely re-usable and standalone, I’d suggest you extract it to a separate library. You can still have dependencies on individual components (shameless plug: you could manage those dependencies through composer, which will be used by Symfony 2.1).
If you decide to go down that path, the bundle simply integrates the library into Symfony2 by providing DI container configuration for it.