If this code does not need to be reused outside of Symfony2 projects, you can simply put it in your package.
I would go for something like:
Acme\HtmlCleanerBundle\Cleaner\SimpleCleaner.php
Since this is a package, you can extract it into a separate package and reuse it for other Symfony2 projects.
If you want the code to be completely reusable and standalone, I would suggest you extract it into a separate library. You still have dependencies on individual components (shameless plugin: you can manage these dependencies through composer , which will be used by Symfony 2.1).
If you decide to go this route, the package simply integrates the library into Symfony2, providing it with a DI container configuration.
igorw source share