Cover of the book Symfony 5: The Fast Track

Symfony 5: The Fast Track is the best book to learn modern Symfony development, from zero to production. +300 pages in full color showing how to combine Symfony with Docker, APIs, queues & async tasks, Webpack, Single-Page Applications, etc.

Buy printed version

New in Symfony 4.3: Exclude More Files with Finder

Contributed by
Ahmed Abdou
in #30448.

The Finder component helps you find files and directories based on different criteria (file name, size, contents, modification time, etc.). It's one of those Symfony components with a modest purpose but hugely successful (more than 100 million downloads and thousands of projects depending on it).

When using Version Control Systems (or "VCS" for short) such as Git, this component ignores by default their metadata files in the search results (you can control this behavior with the ignoreVCS() method).

In Symfony 4.3 we improved this component to let you ignore any file or directory that matches the patterns defined in the .gitignore file. To do so, call to the new ignoreVCSIgnored() method (and make sure that your .gitignore file exists and is readable):

use Symfony\Component\Finder\Finder;

$finder = (new Finder())
    // ...

New in Symfony 4.3: Exclude More Files with Finder

Tweet this


Does it look in all parent directories for .gitignore file?
@Thomas No parent directory lookup, looks like Stof is already on it:

Comments are closed.

To ensure that comments stay relevant, they are closed for old posts.