Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Generated on May 2, 2024 via composer

psr/http-factory 1.0.2

Common interfaces for PSR-7 HTTP message factories
Package summary
Share
0
issues
1
license
1
MIT
Package created
30 Jul 2018
Version published
10 Apr 2023
Maintainers
3
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
psr/http-factory@1.0.2
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of psr/http-factory 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does psr/http-factory do?

The psr/http-factory is a composer package that provides interface-related elements for PSR-17 HTTP factories. PSR-17 encompasses HTTP factories that are utilized in the creation of HTTP objects while adhering to certain standards. It's important to note that the package doesn't have a HTTP Factory implementation of its own, but rather, it details the components that define a HTTP Factory.

How do you use psr/http-factory?

To use psr/http-factory, you must first require it in your PHP project using Composer. This can be done by running the command composer require psr/http-factory. Using psr/http-factory largely depends on the specific PSR-17 factory implementation you need. Here is a basic example of usage:

use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamFactoryInterface;

class MyClass
{
    private $responseFactory;
    private $streamFactory;

    public function __construct(ResponseFactoryInterface $responseFactory, StreamFactoryInterface $streamFactory)
    {
        $this->responseFactory = $responseFactory;
        $this->streamFactory = $streamFactory;
    }

    public function doSomething(): ResponseInterface
    {
        $response = $this->responseFactory->createResponse(200);

        $stream = $this->streamFactory->createStream('hello world');
        $response = $response->withBody($stream);

        return $response;
    }
}

In the example given, we're injecting our PSR-17 factories into our class and then using them to generate a response. Although our dependency injection needs aren't addressed in this example, they would be handled in our container or factory that creates MyClass.

Where are the psr/http-factory docs?

The official documentation for the psr/http-factory is hosted at the PHP-FIG website under PSR-17, which can be accessed directly from this link. In addition, relevant information about the package and its implementations can also be found on its Packagist listing and through the providers of psr/http-factory-implementations on Packagist.

All Versions