copyFilteredFilesWithMetadata.php
Table of Contents
Functions
- copyFilteredFilesWithMetadata() : void
- Copies the filtered files of a directory into a destination directory and, optionally, embeds a `.metadata.json` file describing the archive.
Functions
copyFilteredFilesWithMetadata()
Copies the filtered files of a directory into a destination directory and, optionally, embeds a `.metadata.json` file describing the archive.
copyFilteredFilesWithMetadata(string $sourceDir, string $destDir[, array<string|int, string> $excludePatterns = [] ][, callable|null $filterCallback = null ][, array<string, mixed> $metadata = [] ]) : void
This is the staging step shared by the directory-archiving helpers (tarDirectory() and zipDirectory()): it delegates the copy to copyFilteredFiles(), writes the metadata when provided, and guarantees the destination is non-empty.
Embedding metadata always makes the destination non-empty, even when no source file
matched the filters (the archive then contains only .metadata.json).
Parameters
- $sourceDir : string
-
The source directory to copy from.
- $destDir : string
-
The destination (staging) directory to copy into.
- $excludePatterns : array<string|int, string> = []
-
Glob patterns or file names to exclude.
- $filterCallback : callable|null = null
-
Optional
function (string $filepath): boolreturningtrueto include the item. - $metadata : array<string, mixed> = []
-
Optional metadata embedded as
.metadata.json.