mirror of
https://github.com/Ne-Lexa/php-zip.git
synced 2025-09-01 19:12:36 +02:00
update README
This commit is contained in:
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