php-http/multipart-stream-builder
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
php-http/discovery | 1.19.4 | - | MIT | prod |
The php-http/multipart-stream-builder is a useful tool that helps in creating multipart PSR-7 streams. The unique advantage of this package is that it allows you to create streams independently from any PSR-7 implementation. This becomes particularly beneficial in contexts where you need to handle multi-part form data in your PHP applications. The builder enables you to add binary data and fields to requests and handle complex content types like nested multiparts.
To utilize the php-http/multipart-stream-builder in your project, you will first require the use of Composer. You can install the package using the following command on your terminal:
$ composer require php-http/multipart-stream-builder
Please remember that prerequisites include having PHP and Composer installed on your system.
Though not supplied in the document, a typical usage might look something like this:
use Http\Message\MultipartStream\MultipartStreamBuilder;
use Http\Message\StreamFactory\GuzzleStreamFactory;
// Create a stream factory.
$streamFactory = new GuzzleStreamFactory();
// Instantiate a MultipartStreamBuilder with that factory.
$builder = new MultipartStreamBuilder($streamFactory);
// Add a resource to the multipart stream.
$resource = fopen('/path/to/a/file', 'r');
$builder->addResource('file', $resource, ['filename' => 'filename.jpg']);
// Get the resulting stream.
$multipartStream = $builder->build();
// Get the boundary.
$boundary = $builder->getBoundary();
Please note that you need to add the necessary use statements and replace '/path/to/a/file' and 'filename.jpg' with actual data. Always configure and tweak the code according to your use case.
The extensive documentation for the php-http/multipart-stream-builder can be found on the official documentation page. This documentation comprises comprehensive details about the package, including how to use it, various functionalities it offers and a host of examples to guide you through the entire process.