Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laminas Diactoros Laravel Package

laminas/laminas-diactoros

PSR-7 HTTP message implementation (ServerRequest, Request, Response, Stream, UploadedFile, Uri) for PHP. Includes factories and utilities for creating and normalizing requests/responses, with strong type coverage and interoperability with PSR-17/PSR-15.

View on GitHub
Deep Wiki
Context7

Serialization

String

At times, it's useful to either create a string representation of a message (serialization), or to cast a string or stream message to an object (deserialization). This package provides features for this in Laminas\Diactoros\Request\Serializer and Laminas\Diactoros\Response\Serializer; each provides the following static methods:

  • fromString($message) will create either a Request or Response instance (based on the serializer used) from the string message.
  • fromStream(Psr\Http\Message\StreamInterface $stream) will create either a Request or Response instance (based on the serializer used) from the provided stream.
  • toString(Psr\Http\Message\RequestInterface|Psr\Http\Message\ResponseInterface $message) will create either a string from the provided message.

The deserialization methods (from*()) will raise exceptions if errors occur while parsing the message. The serialization methods (toString()) will raise exceptions if required data for serialization is not present in the message instance.

Array

This package also provides features for array serialization using Laminas\Diactoros\Request\ArraySerializer and Laminas\Diactoros\Response\ArraySerializer; each provides the following static methods:

  • fromArray(array $message) will create either a Request or Response instance (based on the serializer used) from the array message.
  • toArray(Psr\Http\Message\RequestInterface|Psr\Http\Message\ResponseInterface $message) will create an array from the provided message.

The deserialization methods (fromArray()) will raise exceptions if errors occur while parsing the message.

Example Usage

Array serialization can be usesful for log messages:

class LoggerMiddleware
{
    /**
     * [@var](https://github.com/var) \Psr\Log\LoggerInterface
     */
    protected $logger;

    public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next)
    {
        $response = $next($request, $response);

        $this->logger->debug('Request/Response', [
            'request' => \Laminas\Diactoros\Request\ArraySerializer::toArray($request),
            'response' => \Laminas\Diactoros\Response\ArraySerializer::toArray($response),
        ]);

        return $response;
    }
}
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport