Why I can't get Symfony Finder like a service?
The Symfony's Finder component is a standalone component, it is not a part of the FileSystem component:
- http://symfony.com/doc/current/components/finder.html
- http://symfony.com/doc/current/components/filesystem.html
There is no "finder" service because a Finder instance is an object that needs to be manipulated to work. And as objects are always passed by reference, if someone modifies the service once, everyone will see those changes. This is not what you want for this component.
But you can create your own service as a Finder instance and use this service only in another service (as a dependency).
To complement Yann Eugone's answer with some code. This is how you could create your own FinderService from the ServiceComponent and inject into other services.
services.yml
std.symfony_finder:
class: Symfony\Component\Finder\Finder
public: false
std.your_service:
class: Std\AppBundle\Services\YourService
arguments: [@std.symfony_finder]