PHPackages                             wickedbyte/http-tortilla - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. wickedbyte/http-tortilla

ActiveLibrary[HTTP &amp; Networking](/categories/http)

wickedbyte/http-tortilla
========================

Set of traits that make wrapping PSR-7 objects easier.

v3.0.0(1mo ago)09↓100%1MITPHPPHP ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0CI passing

Since Nov 25Pushed 1mo agoCompare

[ Source](https://github.com/wickedbyte/http-tortilla)[ Packagist](https://packagist.org/packages/wickedbyte/http-tortilla)[ Docs](https://github.com/wickedbyte/http-tortilla)[ RSS](/packages/wickedbyte-http-tortilla/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (10)Versions (8)Used By (1)

HTTP Tortilla - HTTP Message (PSR-7) Wrapper
============================================

[](#http-tortilla---http-message-psr-7-wrapper)

> This project is an independently maintained fork of [phoneburner/http-tortilla](https://github.com/phoneburner/http-tortilla), originally released under the MIT license, by the original project authors. This fork is neither affiliated with nor endorsed by PhoneBurner.

This library provides a simple set of traits to allow wrapping (or decoration) of various PSR-7 classes. Wrapping the classes allows easy addition of convenience methods while maintaining compatibility with code that relies on the underlying PSR interfaces.

Requirements
------------

[](#requirements)

- PHP &gt;= 8.2
- [`psr/http-message`](https://github.com/php-fig/http-message) ^1.1 || ^2.0

This package works with either v1.1 or v2.0 of the PSR-7 interfaces, but does not provide the actual implementations to be wrapped. Those can be found in other packages, e.g. [`guzzlehttp/psr-7`](https://github.com/guzzle/psr7) or [Laminas Diactoros](https://github.com/laminas/laminas-diactoros).

Installation
------------

[](#installation)

The preferred method of installation is to use [Composer](https://getcomposer.org/):

```
composer require wickedbyte/http-tortilla
```

Usage
-----

[](#usage)

To add behaviour to a PSR-7 object that implements `MessageInterface` or one of its subclasses, `use` the matching wrapper trait, and call `setMessage($message)` to wrap the target object.

Once `setMessage($message)` is called, all interface methods will be proxied to the original object. Any of those methods can be redefined, however, most usage will probably be adding *additional* convenience methods to the object.

Because most `with*()` methods will likely evolve the *wrapped* object as the method is proxied to that underlying object. To maintain the wrapping through various calls to `with*()`, `setFactory($callable)` allows a callable that returns a wrapped object when given the product of the underlying `with*()` message.

If the underlying object needs to be accessed, `getMessage()` may be used.

```
