Skip to content

Add example for Finder::exclude #9158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 29, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions components/finder.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,27 @@ Exclude directories from matching with the
The :method:`Symfony\\Component\\Finder\\Finder::ignoreUnreadableDirs`
method was introduced in Symfony 2.3.

Note that the excluded paths provided are relative to the `in()` directories. For
example if you have:

/path/to/project
\-- A/
|-- a0
|-- a1
\-- B
|-- b0
\-- b1

And do the following:

Finder::create()
->files()
->in('/path/to/project)
->exclude('A/B')
;

Then the finder will collect the files `a0` and `a1`.

It's also possible to ignore directories that you don't have permission to read::

$finder->ignoreUnreadableDirs()->in(__DIR__);
Expand Down