1
0
mirror of https://github.com/Ne-Lexa/php-zip.git synced 2025-07-18 22:51:11 +02:00

update README

This commit is contained in:
wapplay
2018-10-10 07:41:19 +03:00
parent e1866215a6
commit 062762ed09
2 changed files with 46 additions and 30 deletions

View File

@@ -78,6 +78,7 @@
```php
// создание нового архива
$zipFile = new \PhpZip\ZipFile();
try{
$zipFile
->addFromString("zip/entry/filename", "Is file content") // добавить запись из строки
->addFile("/path/to/file", "data/tofile") // добавить запись из файла
@@ -93,6 +94,13 @@ $zipFile
->addFromString('dir/file.txt', 'Test file') // добавить новую запись из строки
->setPassword('password') // установить пароль на все записи
->outputAsAttachment('library.jar'); // вывести в браузер без сохранения в файл
}
catch(\PhpZip\Exception\ZipException $e){
// обработка исключения
}
finally{
$zip->close();
}
```
Другие примеры можно посмотреть в папке `tests/`.

View File

@@ -78,6 +78,7 @@ Latest stable version: [![Latest Stable Version](https://poser.pugx.org/nelexa/z
```php
// create new archive
$zipFile = new \PhpZip\ZipFile();
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
@@ -93,6 +94,13 @@ $zipFile
->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