TLDR version:
how to utilize PharData::buildFromIterator in order to build .tar archive from /path/to/project/, but excluding a list of files, like /path/to/project/file0.txt, /path/to/project/file1.txt, /path/to/project/file2.txt?
Longer version, what-have-I-tried included:
In order to build .tar archive from dir path, I tried with the simple PharData::buildFromDirectory method which has a second, optional argument which... kind of... does exact opposite of what I need
"pcre regular expression [...] Only file paths matching the regular expression will be included in the archive"
. So I guess, the only option left is to utilize PharData::buildFromIterator which has a simple usage example:
$phar->buildFromIterator(
new RecursiveIteratorIterator(
new RecursiveDirectoryIterator('/path/to/project', FilesystemIterator::SKIP_DOTS)
),
'/path/to/project'
);
This example may be a starting point but from here I do not know how to exclude a list of files from iterator?
In case someone finds this question useful, I shall post an answer since I have figured it out how to do it, with solutions to similar problem found here, thanks to user Levi Morrison.
(tested OK on Windows filesystem, assumes
__DIR__is the directory where it runs)