Zip
class Winter\Storm\Filesystem\Zip
extends ZipArchive
Extends
Class | Description |
---|---|
ZipArchive
|
Properties
protected
$folderPrefix
:
string
= ""
Folder prefix
Methods
public final __construct ()
Lock down the constructor for this class.
public
add (string $source, array $options = []
)
: self
Adds a source file or directory to a Zip file.
Property | Type | Description |
---|---|---|
$source | string |
string
Path to the source file or directory. |
$options | array |
array
Optional. An array of options. Supports the following options:
|
public
static
extract (string $source, string $destination, array $options = []
)
: bool
Extracts an existing ZIP file.
Property | Type | Description |
---|---|---|
$source | string |
string
Path to the ZIP file. |
$destination | string |
string
Path to the destination directory. |
$options | array |
array
Optional. An array of options. Only one option is currently supported:
|
public
folder (string $name, $source = null
)
: self
Creates a new folder inside the Zip file, and optionally adds the given source files/folders to this folder.
Source can be a single path, an array of paths or a callback which allows you to manipulate the Zip file.
Property | Type | Description |
---|---|---|
$name | string |
string
|
$source | mixed |
mixed
|
public
static
make (string $destination, string | callable | array | null $source = null
, array $options = []
)
: static
Creates a new empty Zip file, optionally populating it with given source files.
Source can be a single path, an array of paths or a callback which allows you to manipulate the Zip file.
Property | Type | Description |
---|---|---|
$destination | string |
string
Path to the destination ZIP file. |
$source | string | callable | array | null |
string | callable | array | null
Optional. Path to the source file(s) or a callback. |
$options | array |
array
Optional. An array of options. Uses the same options as |
public remove (array | string $source) : self
Removes file(s) or folder(s) from the Zip file.
Does not support wildcards.
Property | Type | Description |
---|---|---|
$source | array | string |
array | string
|
protected removePathPrefix (string $prefix, string $path) : string
Removes a prefix from a given path.
Property | Type | Description |
---|---|---|
$prefix | string |
string
|
$path | string |
string
|