talira

nyholm/psr7

Small, strict and fast PSR-7 and PSR-17 implementation for PHP

open sourceMITfree

nyholm/psr7 is a lightweight PHP implementation of the PSR-7 HTTP message interfaces and the PSR-17 factories that create them, in about 1,000 lines. Its objects carry no public methods beyond what PSR-7 defines, it passes the PSR-7 integration tests in full, and its README benchmark puts it ahead of Guzzle's, Laminas' and Slim's implementations. Requests built with it can be sent with HTTPlug or any PSR-18 client, Symfony Flex registers its factories as services, and the companion nyholm/psr7-server package builds server requests from PHP's superglobals. Its author is Tobias Nyholm.

Problems it solves

  • create PSR-7 request and response objects in PHP without pulling in Guzzle
  • pick a PSR-17 factory to pass to a PSR-18 HTTP client in PHP
  • use a fast, standards-strict HTTP message library in a PHP framework

Features

  • Full PSR-7 HTTP message implementation
  • PSR-17 factories for requests, responses, streams and URIs
  • No public methods beyond the PSR-7 specification
  • Works with HTTPlug and any PSR-18 HTTP client
  • Symfony Flex registers its factories as services

Alternatives

The same job

These do what nyholm/psr7 does.

  1. laminas-diactoros PSR-7 HTTP messages and PSR-17 factories for PHP, from Laminas
  2. HTTP Factory for Guzzle PSR-17 HTTP factory implemented on Guzzle's PSR-7 messages
  3. Slim-Psr7 Strict PSR-7 HTTP message implementation from the Slim Framework

Compare nyholm/psr7 with the top 3