Exclude files relative to the root of the project

Author: glen-84Created Apr 27, 2016Updated Apr 24, 2026
LabelsType: enhancementCore Component: Config & Ruleset & CLI options

I want to be able to exclude everything under the /data folder. There appear to be two options here, neither of which solve the problem:

  1. <exclude-pattern>*/data/*</exclude-pattern> – this will exclude files under any data folder, not just the one in the root of the project.
  2. <exclude-pattern type="relative">^/data/*</exclude-pattern> – this will exclude files under the data folder, but it won't work if you run phpcs for a specific file (which is how I assume most editor extensions work).

Is it somehow possible to have an exclusion of /data/* that works relative to the root of the project?

Source: squizlabs/PHP_CodeSniffer