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

Streams Laravel Package

spiral/streams

spatial/streams is a lightweight PHP stream utility for working with data as readable/writable streams. It provides simple abstractions to compose, transform, and pipe stream content, useful for file handling, IO workflows, and integrating stream-based APIs.

View on GitHub
Deep Wiki
Context7

Getting Started

This package provides PSR-7-compliant stream wrapper implementations for PHP—specifically, it supplies lightweight, reusable stream classes (Stream, BufferedStream, TemporaryStream, etc.) that implement Psr\Http\Message\StreamInterface. Since it's a subtree split of the Spiral Framework’s Streams component and is now archived/readonly, it's primarily useful in legacy Spiral applications or projects requiring minimal PSR-7 stream dependencies.

To begin:

  1. Require via Composer: composer require spiral/streams
  2. Implement PSR-7 StreamInterface usage wherever streams are needed (e.g., HTTP clients, middleware, file processing)
  3. Start with Spiral\Streams\Stream::create($resourceOrString) to instantiate streams from strings or resources

The most common first use case is as a dependency for PSR-17/PSR-15/PSR-7 tooling—e.g., creating response bodies or request payloads in middleware.

Implementation Patterns

  • Consistent Stream Construction: Use Stream::create() instead of manually instantiating—this handles resource detection and proper initialization.
  • Memory Optimization: Use BufferedStream for streams that require repeated reads without seeking or copying.
  • Temporary Workflows: For file upload staging, temp-streaming, or in-memory transformation pipelines, TemporaryStream provides safe temp file handling.
  • Integration with frameworks: Though Spiral is the original consumer, these streams integrate cleanly with any PSR-15 middleware stack (e.g., Slim, Laminas Stratigility, Symfony HTTP kernel) or HTTP client (e.g., Guzzle’s stream factory can consume them).

Typical workflow:

$stream = Spiral\Streams\Stream::create(fopen('php://temp', 'r+'));
$stream->write(json_encode($payload));
$response = new Response($stream, 200, ['Content-Type' => 'application/json']);

Gotchas and Tips

  • ⚠️ Last release in 2019: This package is effectively unmaintained. Consider substituting symfony/http-foundation’s StreamedResponse, nyholm/psr7, or guzzlehttp/psr7 for new projects—these have broader ecosystem support and active maintenance.
  • ⚠️ Subtree split artifact: As a read-only split, this does not include the full Spiral Framework’s internal utilities (e.g., no StreamDecoratorTrait or advanced adapters). Only core stream classes are present.
  • 🔧 Resource handling: Be cautious with fopen()-returned resources—ensure they’re binary-safe ('rb' or 'r+b') to avoid line-ending translation issues on Windows.
  • 🔍 Debugging: Use $stream->detach() to retrieve the underlying resource for logging or third-party tools (e.g., stream_get_contents()).
  • 🛠️ Extensibility: Since it’s PSR-7-only, extend by composing the Stream class—e.g., wrap it in a decorator to add encryption or compression. Avoid subclassing unless needed; composition is safer and more testable.
  • 📦 Composer conflicts: Due to its age and split nature, may conflict with modern PSR-7 implementations. Pin version explicitly if used in legacy contexts: "spiral/streams": "^1.0"
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