PHP Класс Chumper\Zipper\Zipper

Class Zipper
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__construct ( Illuminate\Filesystem\Filesystem $fs = null ) Constructor
__destruct ( ) Destructor
add ( $pathToAdd, $fileName = null ) Add one or multiple files to the zip.
addEmptyDir ( $dirName ) : void Add an empty directory
addString ( $filename, $content ) Add a file to the zip using its contents
close ( ) Closes the zip file and frees all handles
contains ( $fileInArchive ) : boolean Checks if a file is present in the archive
delete ( ) Deletes the archive file
extractTo ( $path, array $files = [], integer $method = Zipper::BLACKLIST ) Extracts the opened zip archive to the specified location
you can provide an array of files and folders and define if they should be a white list or a black list to extract.
folder ( $path ) Sets the internal folder to the given path.
Useful for extracting only a segment of a zip file.
getArchiveType ( ) : string Get the type of the Archive
getCurrentFolderPath ( ) : string Get the current internal folder pointer
getFileContent ( $filePath ) : mixed Gets the content of a single file if available
getFileHandler ( ) : Illuminate\Filesystem\Filesystem
getFilePath ( ) : string Returns the path of the current zip file if there is one.
getInternalPath ( ) : string Gets the path to the internal folder
getRepository ( ) : Chumper\Zipper\Repositories\RepositoryInterface
getStatus ( ) : integer Gets the status of the zip.
home ( ) Resets the internal folder to the root of the zip file.
listFiles ( ) : array List files that are within the archive
make ( $pathToFile, Chumper\Zipper\Repositories\RepositoryInterface | string $type = 'zip' ) Create a new zip Archive if the file does not exists opens a zip archive if the file exists
phar ( $pathToFile ) Create a new phar file or open one
rar ( $pathToFile ) Create a new rar file or open one
remove ( $fileToRemove ) Remove a file or array of files and folders from the zip archive
usePassword ( $password ) : boolean Sets the password to be used for decompressing
zip ( $pathToFile ) Create a new zip archive or open an existing one

Приватные методы

Метод Описание
addDir ( $pathToDir )
addFile ( $pathToAdd, $fileName = null ) Add the file to the zip
addFromString ( $filename, $content ) Add the file to the zip from content
createArchiveFile ( $pathToZip ) : boolean
extractWithBlackList ( $path, $filesArray )
extractWithWhiteList ( $path, $filesArray )

Описание методов

__construct() публичный Метод

Constructor
public __construct ( Illuminate\Filesystem\Filesystem $fs = null )
$fs Illuminate\Filesystem\Filesystem

__destruct() публичный Метод

Destructor
public __destruct ( )

add() публичный Метод

Add one or multiple files to the zip.
public add ( $pathToAdd, $fileName = null )
$pathToAdd array|string An array or string of files and folders to add

addEmptyDir() публичный Метод

Add an empty directory
public addEmptyDir ( $dirName ) : void
$dirName
Результат void

addString() публичный Метод

Add a file to the zip using its contents
public addString ( $filename, $content )
$filename string The name of the file to create
$content string The file contents

close() публичный Метод

Closes the zip file and frees all handles
public close ( )

contains() публичный Метод

Checks if a file is present in the archive
public contains ( $fileInArchive ) : boolean
$fileInArchive
Результат boolean

delete() публичный Метод

Deletes the archive file
public delete ( )

extractTo() публичный Метод

Extracts the opened zip archive to the specified location
you can provide an array of files and folders and define if they should be a white list or a black list to extract.
public extractTo ( $path, array $files = [], integer $method = Zipper::BLACKLIST )
$path string The path to extract to
$files array An array of files
$method integer The Method the files should be treated

folder() публичный Метод

Sets the internal folder to the given path.
Useful for extracting only a segment of a zip file.
public folder ( $path )
$path

getArchiveType() публичный Метод

Get the type of the Archive
public getArchiveType ( ) : string
Результат string

getCurrentFolderPath() публичный Метод

Get the current internal folder pointer
public getCurrentFolderPath ( ) : string
Результат string

getFileContent() публичный Метод

Gets the content of a single file if available
public getFileContent ( $filePath ) : mixed
$filePath string The full path (including all folders) of the file in the zip
Результат mixed returns the content or throws an exception

getFileHandler() публичный Метод

public getFileHandler ( ) : Illuminate\Filesystem\Filesystem
Результат Illuminate\Filesystem\Filesystem

getFilePath() публичный Метод

Returns the path of the current zip file if there is one.
public getFilePath ( ) : string
Результат string The path to the file

getInternalPath() публичный Метод

Gets the path to the internal folder
public getInternalPath ( ) : string
Результат string

getRepository() публичный Метод

public getRepository ( ) : Chumper\Zipper\Repositories\RepositoryInterface
Результат Chumper\Zipper\Repositories\RepositoryInterface

getStatus() публичный Метод

Gets the status of the zip.
public getStatus ( ) : integer
Результат integer The status of the internal zip file

home() публичный Метод

Resets the internal folder to the root of the zip file.
public home ( )

listFiles() публичный Метод

List files that are within the archive
public listFiles ( ) : array
Результат array

make() публичный Метод

Create a new zip Archive if the file does not exists opens a zip archive if the file exists
public make ( $pathToFile, Chumper\Zipper\Repositories\RepositoryInterface | string $type = 'zip' )
$pathToFile string The file to open
$type Chumper\Zipper\Repositories\RepositoryInterface | string The type of the archive, defaults to zip, possible are zip, phar

phar() публичный Метод

Create a new phar file or open one
public phar ( $pathToFile )
$pathToFile

rar() публичный Метод

Create a new rar file or open one
public rar ( $pathToFile )
$pathToFile

remove() публичный Метод

Remove a file or array of files and folders from the zip archive
public remove ( $fileToRemove )
$fileToRemove array|string The path/array to the files in the zip

usePassword() публичный Метод

Sets the password to be used for decompressing
public usePassword ( $password ) : boolean
$password
Результат boolean

zip() публичный Метод

Create a new zip archive or open an existing one
public zip ( $pathToFile )
$pathToFile