mirror of
https://github.com/Ne-Lexa/php-zip.git
synced 2025-07-18 14:41:13 +02:00
update README
This commit is contained in:
38
README.RU.md
38
README.RU.md
@@ -78,21 +78,29 @@
|
||||
```php
|
||||
// создание нового архива
|
||||
$zipFile = new \PhpZip\ZipFile();
|
||||
$zipFile
|
||||
->addFromString("zip/entry/filename", "Is file content") // добавить запись из строки
|
||||
->addFile("/path/to/file", "data/tofile") // добавить запись из файла
|
||||
->addDir(__DIR__, "to/path/") // добавить файлы из директории
|
||||
->saveAsFile($outputFilename) // сохранить архив в файл
|
||||
->close(); // закрыть архив
|
||||
|
||||
// открытие архива, извлечение файлов, удаление файлов, добавление файлов, установка пароля и вывод архива в браузер.
|
||||
$zipFile
|
||||
->openFile($outputFilename) // открыть архив из файла
|
||||
->extractTo($outputDirExtract) // извлечь файлы в заданную директорию
|
||||
->deleteFromRegex('~^\.~') // удалить все скрытые (Unix) файлы
|
||||
->addFromString('dir/file.txt', 'Test file') // добавить новую запись из строки
|
||||
->setPassword('password') // установить пароль на все записи
|
||||
->outputAsAttachment('library.jar'); // вывести в браузер без сохранения в файл
|
||||
try{
|
||||
$zipFile
|
||||
->addFromString("zip/entry/filename", "Is file content") // добавить запись из строки
|
||||
->addFile("/path/to/file", "data/tofile") // добавить запись из файла
|
||||
->addDir(__DIR__, "to/path/") // добавить файлы из директории
|
||||
->saveAsFile($outputFilename) // сохранить архив в файл
|
||||
->close(); // закрыть архив
|
||||
|
||||
// открытие архива, извлечение файлов, удаление файлов, добавление файлов, установка пароля и вывод архива в браузер.
|
||||
$zipFile
|
||||
->openFile($outputFilename) // открыть архив из файла
|
||||
->extractTo($outputDirExtract) // извлечь файлы в заданную директорию
|
||||
->deleteFromRegex('~^\.~') // удалить все скрытые (Unix) файлы
|
||||
->addFromString('dir/file.txt', 'Test file') // добавить новую запись из строки
|
||||
->setPassword('password') // установить пароль на все записи
|
||||
->outputAsAttachment('library.jar'); // вывести в браузер без сохранения в файл
|
||||
}
|
||||
catch(\PhpZip\Exception\ZipException $e){
|
||||
// обработка исключения
|
||||
}
|
||||
finally{
|
||||
$zip->close();
|
||||
}
|
||||
```
|
||||
Другие примеры можно посмотреть в папке `tests/`.
|
||||
|
||||
|
38
README.md
38
README.md
@@ -78,21 +78,29 @@ Latest stable version: [;
|
||||
$zipFile
|
||||
->addFromString("zip/entry/filename", "Is file content") // add an entry from the string
|
||||
->addFile("/path/to/file", "data/tofile") // add an entry from the file
|
||||
->addDir(__DIR__, "to/path/") // add files from the directory
|
||||
->saveAsFile($outputFilename) // save the archive to a file
|
||||
->close(); // close archive
|
||||
|
||||
// open archive, extract, add files, set password and output to browser.
|
||||
$zipFile
|
||||
->openFile($outputFilename) // open archive from file
|
||||
->extractTo($outputDirExtract) // extract files to the specified directory
|
||||
->deleteFromRegex('~^\.~') // delete all hidden (Unix) files
|
||||
->addFromString('dir/file.txt', 'Test file') // add a new entry from the string
|
||||
->setPassword('password') // set password for all entries
|
||||
->outputAsAttachment('library.jar'); // output to the browser without saving to a file
|
||||
try{
|
||||
$zipFile
|
||||
->addFromString("zip/entry/filename", "Is file content") // add an entry from the string
|
||||
->addFile("/path/to/file", "data/tofile") // add an entry from the file
|
||||
->addDir(__DIR__, "to/path/") // add files from the directory
|
||||
->saveAsFile($outputFilename) // save the archive to a file
|
||||
->close(); // close archive
|
||||
|
||||
// open archive, extract, add files, set password and output to browser.
|
||||
$zipFile
|
||||
->openFile($outputFilename) // open archive from file
|
||||
->extractTo($outputDirExtract) // extract files to the specified directory
|
||||
->deleteFromRegex('~^\.~') // delete all hidden (Unix) files
|
||||
->addFromString('dir/file.txt', 'Test file') // add a new entry from the string
|
||||
->setPassword('password') // set password for all entries
|
||||
->outputAsAttachment('library.jar'); // output to the browser without saving to a file
|
||||
}
|
||||
catch(\PhpZip\Exception\ZipException $e){
|
||||
// handle exception
|
||||
}
|
||||
finally{
|
||||
$zip->close();
|
||||
}
|
||||
```
|
||||
Other examples can be found in the `tests/` folder
|
||||
|
||||
|
Reference in New Issue
Block a user