tar.php
Table of Contents
Functions
- tar() : string
- Creates a tar archive from one or more files and/or directories.
Functions
tar()
Creates a tar archive from one or more files and/or directories.
tar(string|array<string|int, string> $paths[, string|null $outputPath = null ][, string|null $compression = CompressionType::GZIP ][, string|null $preserveRoot = null ]) : string
This function supports adding multiple paths (files or directories) to a tar archive, with optional compression (gzip, bzip2, or none). It can preserve the root directory structure inside the archive, and generates a unique temporary archive if no output path is specified.
Empty directories are preserved in the archive.
Parameters
- $paths : string|array<string|int, string>
-
Absolute path(s) to file(s) or directory(ies) to include in the archive.
- $outputPath : string|null = null
-
Optional full path to the final archive file to create. If null, an automatic unique filename with timestamp is generated in the system temp directory.
- $compression : string|null = CompressionType::GZIP
-
Compression type to use on the tar archive. Supported values are defined in CompressionType, defaults to CompressionType::GZIP.
- $preserveRoot : string|null = null
-
If set, paths inside the archive will be stored relative to this directory, allowing to preserve directory structure when extracting. Must be an absolute path.
Tags
Return values
string —Returns the full path to the created tar archive file.