Download the PHP package stechstudio/laravel-zipstream without Composer

On this page you can find all versions of the php package stechstudio/laravel-zipstream. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-zipstream

Streaming Zips with Laravel

Latest Version on Packagist Total Downloads Build Status

A fast and simple streaming zip file downloader for Laravel.

Quickstart

1. Install the package

The service provider and facade will be automatically wired up.

2. In a controller method call the create method on the Zip facade

That's it! A StreamedResponse will be returned and the zip contents built and streamed out. The user's browser will begin downloading a package.zip file immediately.

Customize the internal zip path for a file

By default any files you add will be stored in the root of the zip, with their original filenames.

You can customize the filename and even create subfolders within the zip by providing your files array with key/value pairs:

Fluent usage

You can also provide your files one at a time:

Add HTTP file sources

You can add HTTP URLs as the source filepath. Note that zip filesize can only be calculated up front if the HTTP source provides a Content-Length header, not all URLs do.

Add raw file data

You can provide raw data instead of a filepath:

Support for S3

Install AWS sdk and configure S3

You can stream files from S3 into your zip.

  1. Install the aws/aws-sdk-php package

  2. Setup an AWS IAM user with s3:GetObject permission for the S3 bucket and objects you intend to zip up.

  3. Store your credentials as AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and AWS_DEFAULT_REGION in your .env file.

Add S3 files to your zip

Provide s3:// paths when creating the zip:

By default, this package will try to create an S3 client using the same .env file credentials that Laravel uses. If needed, you can wire up a custom S3 client to the zipstream.s3client container key. Or you can even pass in your own S3 client when adding a file to the zip. To do this, you'll need to create an S3File model instance yourself so that you can provide the client, like this:

Zip size prediction

By default this package attempts to predict the final zip size and sends a Content-Length header up front. This means users will see accurate progress on their download, even though the zip is being streamed out as it is created!

This only works if files are not compressed.

If you have issues with the zip size prediction you can disable it with ZIPSTREAM_PREDICT_SIZE=false in your .env file.

Specify your own filesizes

It can be expensive retrieving filesizes for some file sources such as S3 or HTTP. These require dedicated calls, and can add up to a lot of time if you are zipping up many files. If you store filesizes in your database and have them available, you can drastically improve performance by providing filesizes when you add files. You'll need to make your own File models instead of adding paths directly to the zip.

Let's say you have a collection of Eloquent $files, are looping through and building a zip. If you have a filesize attribute available, it would look something like this:

Configure compression

By default this package uses no compression. Why?

1) This makes building the zips super fast, and is light on your CPU 2) This makes it possible to predict the final zip size as mentioned above.

If you want to compress your zip files set ZIPSTREAM_FILE_METHOD=deflate in your .env file. Just realize this will disable the Content-Length header.

Save Zip to disk

Even though the primary goal of this package is to enable zip downloads without saving to disk, there may be times you'd like to generate a zip on disk as well. And you might as well make use of this package to do so.

Use the saveTo method to write the entire zip to disk immediately. Note that this expects a folder path, the zip name will be appended.

And yes, if you've properly setup and configured S3 you can even save to an S3 bucket/path.

Caching zip while still streaming download

What if you have a lot of users requesting the same zip payload? It might be nice to stream out the zip while also caching it to disk for the future.

Use the cache method to provide a cache path. Note this should be the entire path including filename.

You might use an internal DB id for your cache name, so that the next time a user requests a zip download you can determine if one is already built and just hand it back.

Events

Filename sanitization

By default this package will try to translate any non-ascii character in filename or folder's name to ascii. For example, if your filename is 中文_にほんご_Ч_Ɯ_☺_someascii.txt. It will become __C___someascii.txt using Laravel's Str::ascii($path).

If you need to preserve non-ascii characters, you can disable this feature with an .env setting:

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-zipstream with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1|^8.0
guzzlehttp/guzzle Version ^6.0|^7.0
illuminate/support Version ^5.6|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
maennchen/zipstream-php Version ^v2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package stechstudio/laravel-zipstream contains the following files

Loading the files please wait ....