我想在一个PHP脚本中使用内置的PharData
类创建一个tar存档。
我希望这个tar存档代表一个目录,因此我考虑使用PharData::buildFromDirectory()
来完成。不幸的是,该目录也是一个git仓库,其中包含一个比目录本身还要大的.git
文件夹。
因此,我需要从档案中删除那个.git
目录(最好也将.idea
目录一并删除),因为它会使档案变得过于臃肿。
我到目前为止尝试的方法:
Using a regular expression to filter the directory out:
$archive->buildFromDirectory("..", "@^(?!.git).+@");
Which didn't work.
Using
PharData::delete()
, but unfortunately that seems to only delete a file and not a directory.