Download the PHP package helmich/gridfs without Composer

On this page you can find all versions of the php package helmich/gridfs. 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 gridfs

GridFS implementation for the PHP MongoDB driver

Build Status Code Climate Issue Count Test Coverage

This package provides a userspace implementation of the GridFS specification for PHP's new mongodb extension (not to be confused with the similarly named mongo extension).

This library requires PHP 7!

Author and license

Martin Helmich
This library is MIT-licensed.

Installation

Use Composer:

$ composer require helmich/gridfs

Usage

Initialization

GridFS is oriented around Buckets. For a bucket named $name, this library will create two collections $name.files and $name.chunks in which file metadata and content blocks will be stored. Create a new bucket by instantiating the Helmich\GridFS\Bucket class. You will need a MongoDB\Database instance as dependency and can optionally pass an instance of the Helmich\GridFS\Options\BucketOptions class to configure your bucket:

Uploading files into a bucket

Uploading of files is done via streams. You can open a new upload stream using the openUploadStream function:

Alternatively, use the uploadFromStream method, which takes a PHP stream as a parameter:

Finding uploaded files

Use the find method to find files in your bucket. The find method takes a MongoDB query object as first parameter that is applied to the $bucketName.files collection. The second parameter is an instance of the Helmich\GridFS\Options\FindOptions class in which you can specify advanced options for the search:

Downloading files from a bucket

Downloading files is also stream-oriented. Given the ID of an already existing file, open a new download stream using the openDownloadStream function:

Given an already existing (and writeable) PHP stream, you can also use the downloadToStream method to pipe the file directly into the stream:

There is also a byName variant of both openDownloadStream (openDownloadStreamByName()) and downloadToStream (downloadToStreamByName). Both of these functions take a file name and a Helmich\GridFS\Options\DownloadOptions instance as parameter. The $options parameter allows you to specify which revision of the given filename should be downloaded:

Deleting files

Delete files from the bucket using the delete method:

Gimmicks

PSR-7 adapters

I've implemented this package for a PSR-7 compliant web application. PSR-7 also heavily relies on streams, so I've found it useful to add an adapter class to map a Helmich\GridFS\Stream\DownloadStreamInterface to a Psr\Http\Message\StreamInterface. This is especially useful if you want to return GridFS files as a response body stream. The following example uses the Slim framework, but should be easily adaptable to other PSR-7 compliant frameworks:


All versions of gridfs with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0.0
ext-mongodb Version *
mongodb/mongodb Version ^1.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 helmich/gridfs contains the following files

Loading the files please wait ....