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

Utils Laravel Package

middlewares/utils

Common utilities for Middlewares PSR packages: auto-discovered PSR-7/PSR-17 Factory (Diactoros, Guzzle, Slim, Nyholm, Sunrise) plus PSR-15 Dispatcher for testing, callable handler helpers, and HTTP error exceptions.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Middleware Standardization: Accelerates adoption of PSR-15 middleware patterns in Laravel/PHP applications by providing a unified factory system for PSR-7/PSR-17 objects, reducing dependency sprawl (e.g., Diactoros, Guzzle, Slim).
  • Testing Infrastructure: Enables rapid middleware testing via the Dispatcher class, which simplifies mocking and validation of middleware stacks without requiring full framework integration.
  • Error Handling: Standardizes HTTP error responses with HttpErrorException, improving consistency in API/error handling across microservices or monolithic apps.
  • Build vs. Buy: Justifies buying this package over custom implementations for teams already using PSR-15 middleware (e.g., Laravel middleware, API gateways) to avoid reinventing PSR-7/PSR-17 factories.
  • Use Cases:
    • API Gateways: Centralize request/response creation and middleware dispatching.
    • Testing: Isolate middleware logic in unit tests with the Dispatcher.
    • Legacy Migration: Gradually adopt PSR-15 by wrapping existing middleware in CallableHandler.
    • Multi-Framework Projects: Standardize PSR-7/PSR-17 implementations across Laravel, Lumen, or custom PHP apps.

When to Consider This Package

  • Adopt if:
    • Your team uses PSR-15 middleware (e.g., Laravel middleware, API platforms) and needs a unified PSR-7/PSR-17 factory to avoid vendor lock-in (e.g., Diactoros vs. Guzzle).
    • You’re building testable middleware stacks and want a lightweight Dispatcher for unit/integration tests.
    • Your application requires consistent HTTP error handling with structured context (e.g., problem details for APIs).
    • You’re migrating from Zend Diactoros to Laminas Diactoros or other PSR-17 implementations.
  • Look elsewhere if:
    • You’re not using PSR-15 middleware (e.g., Symfony’s kernel events, Express.js-style middleware).
    • Your project is framework-agnostic and already has a preferred PSR-7/PSR-17 library (e.g., always using Guzzle).
    • You need advanced middleware features (e.g., async support, WebSocket integration) beyond PSR-15.
    • Your team prefers minimal dependencies and can implement factories manually (this package adds ~50KB).

How to Pitch It (Stakeholders)

For Executives: "This package standardizes how our PHP/Laravel applications create HTTP requests/responses and chain middleware, reducing technical debt and improving consistency. It’s like using a single, battle-tested factory for Lego blocks—no more arguing over Diactoros vs. Guzzle. For APIs and microservices, it ensures errors are handled uniformly, and for developers, it speeds up testing and debugging middleware logic. Low risk (MIT license, 50+ stars), high reward for maintainability."

For Engineers: "If you’re tired of configuring PSR-7/PSR-17 factories manually or dealing with Diactoros/Guzzle conflicts, this package auto-detects your preferred libraries and provides a clean API. The Dispatcher class lets you test middleware stacks in isolation, and HttpErrorException gives you structured error responses out of the box. It’s a drop-in solution for any PSR-15 middleware project—just composer require middlewares/utils and start saving time on boilerplate."

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.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky