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

Http Adapter Laravel Package

egeloen/http-adapter

Deprecated HTTP client abstraction for PHP 5.4.8+ that issues requests via multiple adapters (cURL, Guzzle, Buzz, Zend, etc.) and follows PSR-7 message standards. Bugfixes only; new features moved to php-http.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • PSR-7 Compliance: The package adheres to the PSR-7 HTTP Message Standard, making it a strong fit for Laravel (which leverages PSR-7 for HTTP clients like Guzzle). This ensures compatibility with Laravel’s ecosystem (e.g., illuminate/http-client).
  • Adapter Abstraction: Supports 13+ HTTP clients (Guzzle, cURL, ReactPHP, etc.), allowing flexibility in choosing the best-performing or most feature-rich client for specific use cases (e.g., async requests with ReactPHP).
  • Event-Driven Design: Built-in Symfony EventDispatcher integration enables middleware-like behavior (e.g., logging, retries, caching) without reinventing the wheel. Laravel’s service container can easily integrate event subscribers.
  • Deprecation Risk: Officially deprecated in favor of php-http/httplug, which is the modern standard. Migration to httplug should be prioritized long-term.

Integration Feasibility

  • Laravel HTTP Client: Can replace or augment Laravel’s built-in Http client (which uses Guzzle under the hood). The adapter can wrap Guzzle or other clients while maintaining PSR-7 compliance.
  • Middleware Support: Laravel’s middleware system can be mapped to the package’s event subscribers (e.g., logging, retries). Example:
    $httpAdapter = new EventDispatcherHttpAdapter(new GuzzleAdapter());
    $httpAdapter->getEventDispatcher()->addSubscriber(new LoggerSubscriber());
    
  • Service Provider: Can be bootstrapped via Laravel’s Service Provider pattern, injecting the configured adapter into the container.
  • Testing: Near 100% test coverage reduces integration risks, but Laravel-specific edge cases (e.g., queue jobs, sync/async HTTP) should be validated.

Technical Risk

  • Deprecation: High risk due to the package being officially deprecated. New features are unsupported, and maintenance is limited to bugfixes. Recommendation: Evaluate migration to php-http/httplug (e.g., php-http/guzzle7-adapter) as a drop-in replacement.
  • Complexity Overhead: Event-driven architecture adds boilerplate for simple use cases. For basic requests, Laravel’s native Http client may suffice.
  • Async Support: While ReactPHP is supported, Laravel’s async ecosystem (e.g., queues) may require additional abstraction layers.
  • PSR-18 Compliance: httplug is PSR-18 (modern HTTP client standard), whereas this package is PSR-7-focused. Future-proofing favors httplug.

Key Questions

  1. Why not php-http/httplug?
    • Does the team have existing dependencies on this package?
    • Are there unsupported features in httplug that block migration?
  2. Performance Impact
    • How does the event layer affect latency for high-throughput APIs?
    • Is the adapter’s overhead justified by its features (e.g., retries, caching)?
  3. Laravel-Specific Gaps
    • Does Laravel’s Http client handle use cases (e.g., cookie management, redirects) better than this package?
    • Are there conflicts with Laravel’s built-in middleware (e.g., TrustProxies)?
  4. Long-Term Strategy
    • What’s the timeline for migrating to httplug?
    • Can the adapter be incrementally replaced with httplug adapters (e.g., Guzzle, cURL)?

Integration Approach

Stack Fit

  • Laravel Core: Compatible with Laravel’s PSR-7/PSR-18 ecosystem. The adapter can:
    • Replace GuzzleHttp\Client in Illuminate\Http\Client\PendingRequest.
    • Integrate with Laravel’s queue workers for async requests (via ReactPHP adapter).
  • Service Container: The adapter and its dependencies (e.g., event subscribers) can be container-bound:
    $this->app->bind(IvoryHttpAdapter::class, function ($app) {
        $guzzleAdapter = new GuzzleAdapter(new Client());
        return new EventDispatcherHttpAdapter($guzzleAdapter);
    });
    
  • Middleware: Event subscribers map to Laravel middleware. Example:
    Event Subscriber Laravel Middleware Equivalent
    LoggerSubscriber LogRequestMiddleware
    RetrySubscriber Custom retry middleware
    CacheSubscriber CacheResponseMiddleware
  • Testing: Laravel’s Http tests can be adapted to use the adapter, with mocks for event subscribers.

Migration Path

  1. Assessment Phase
    • Audit all HTTP calls in the codebase to identify dependencies on this package.
    • Compare feature parity with php-http/httplug (e.g., guzzle7-adapter).
  2. Incremental Replacement
    • Phase 1: Replace direct Http client usage with the adapter where event-driven features (e.g., retries) are needed.
    • Phase 2: Migrate event subscribers to Laravel middleware or httplug plugins.
    • Phase 3: Replace the adapter with httplug (e.g., Http\Adapter\Guzzle\Guzzle7Adapter).
  3. Deprecation Strategy
    • Use Laravel’s package deprecation tools to warn users before removing support.
    • Example: Add a deprecated() call in the service provider.

Compatibility

  • Guzzle Integration: The Guzzle adapter is fully compatible with Laravel’s default HTTP client. No breaking changes expected.
  • Async Support: ReactPHP adapter can integrate with Laravel’s queue system or Laravel Horizon for async processing.
  • PSR-7/PSR-18: While PSR-7 is backward-compatible with PSR-18, httplug is the future standard. Plan for eventual migration.
  • Event System: Symfony’s EventDispatcher can coexist with Laravel’s events, but custom glue code may be needed for cross-system events.

Sequencing

  1. Proof of Concept
    • Implement a single feature (e.g., retries) using the adapter and compare performance/boilerplate with native Laravel solutions.
  2. Feature-by-Feature Rollout
    • Start with non-critical endpoints (e.g., third-party APIs).
    • Gradually replace internal HTTP calls (e.g., service-to-service).
  3. Testing
    • Validate edge cases: redirects, cookies, auth headers, and async behavior.
    • Ensure backward compatibility with existing tests.
  4. Migration to httplug
    • Once stable, replace the adapter with httplug adapters (e.g., Guzzle, cURL).
    • Update documentation and remove deprecated code.

Operational Impact

Maintenance

  • Bugfixes: Limited to critical issues due to deprecated status. Bug reports should prioritize migration to httplug.
  • Dependency Updates: Requires manual updates to adapters (e.g., Guzzle 6→7). Laravel’s composer.json can enforce version constraints.
  • Event Subscribers: Custom subscribers may need updates if underlying adapters change (e.g., Guzzle breaking changes).
  • Documentation: Outdated docs may mislead developers. Maintain a migration guide to httplug.

Support

  • Debugging: Event-driven architecture adds complexity to debugging. Use:
    • Laravel’s tap() method to inspect requests/responses.
    • Xdebug for event subscriber logic.
  • Performance: Event subscribers (e.g., logging, caching) may introduce latency. Profile with:
    • Laravel Debugbar.
    • Blackfire or XHProf.
  • Async Issues: ReactPHP adapter may require familiarity with non-blocking I/O. Laravel’s queue system can abstract this.

Scaling

  • Horizontal Scaling: Stateless adapters scale well, but shared caching (e.g., CacheSubscriber) requires distributed cache (Redis).
  • Load Testing: Validate under high concurrency, especially with async adapters (e.g., ReactPHP).
  • Resource Usage: Some adapters (e.g., cURL multi-handles) may consume more memory than Guzzle’s connection pooling.

Failure Modes

Failure Scenario Mitigation Strategy
Adapter-specific bugs Use try-catch with HttpAdapterException and fall back to a secondary adapter.
Event subscriber deadlocks Avoid blocking operations in subscribers (e.g., sync DB writes).
Async adapter crashes Implement circuit breakers (e.g., php-http/retry-plugin).
Deprecated package EOL Set a hard deadline for migration to httplug.
Laravel version incompatibilities Test against Laravel’s LTS versions (e.g., 8.x, 9.x, 10.x).

Ramp-Up

  • **
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