Weave 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

Symfony Http Bundle Laravel Package

n7/symfony-http-bundle

A Symfony bundle that packages the HTTP layer into a reusable, configurable component for Symfony applications. It keeps HTTP setup consistent across projects and installs via Composer with sensible defaults and standard bundle configuration.

View on GitHub
Deep Wiki
Context7

Getting Started

First, reset expectations: this is a Symfony bundle, not a Laravel package. There is no service provider, no vendor:publish tag you'll recognize, and no Facade. The mental model shift for a Laravel dev is: bundles are registered in config/bundles.php, configured under a package-specific root key in config/packages/*.yaml, and services are autowired rather than resolved statically through the container.

Minimal steps:

  1. composer require n7/symfony-http-bundle
  2. Register the bundle in config/bundles.php:
    return [
        // ...
        N7\HttpBundle\N7HttpBundle::class => ['all' => true],
    ];
    
    Confirm the exact FQCN from src/ — small packages often rename the class before a 1.0.
  3. Add config at config/packages/n7_http.yaml matching the bundle's Configuration tree.
  4. php bin/console cache:clear (Symfony caches the container aggressively; a stale cache is the #1 source of "my config isn't applied").

Where to look first, in order:

  • README — at 3 stars it is likely thin. Treat it as a hint, not a spec.
  • src/DependencyInjection/Configuration.php — this is the real config schema. Every key, default, and cannotBeEmpty() lives here.
  • src/DependencyInjection/*Extension.php — which services are registered, under what IDs, and with which parameters.
  • src/Resources/config/*.yaml — service definitions, aliases, and tags you'll want to intercept or decorate.
  • src/EventSubscriber/ or src/EventListener/ — if the package hooks the kernel or HTTP client, this is where behavior actually happens.

First use case: inject the bundle's primary service into a controller or console command, fire one request against a sandbox endpoint, and run php bin/console debug:container --tag=<bundle tag> plus debug:config n7_http to confirm the wiring before you build anything on top of it.

Implementation Patterns

Autowire the contract, not the concrete class. Small bundles often ship an interface plus a default implementation. Type-hint the interface in your constructor so you can swap or decorate it later:

public function __construct(private readonly HttpClientInterface $n7Client) {}

If the bundle doesn't register an alias for the interface, register one yourself in config/services.yaml:

services:
    N7\HttpBundle\Contract\SomeInterface:
        alias: n7_http.some_service
        public: false

Config-driven behavior over code. The bundle's value is almost entirely in its config tree. Keep environment-specific settings (base_uri, timeouts, retry counts) in config/packages/n7_http.yaml with %env()% references, and keep business logic out of the YAML entirely.

Compose with Symfony HttpClient. If the bundle wraps HTTP calls, decorate it rather than forking it:

services:
    App\Http\RetryingN7Client:
        decorates: n7_http.client
        arguments: ['@.inner']

This is the Laravel equivalent of swapping a binding — it lets you add logging, retries, or tracing without touching vendor code.

Event subscribers for cross-cutting concerns. If the bundle dispatches events, subscribe to them in your app rather than editing the bundle:

#[AsEventListener(event: 'n7_http.request_failed')]
public function onFailure(SomeEvent $event): void { /* ... */ }

Test with KernelTestCase and mocked transports. Symfony's MockHttpClient is your friend when the bundle depends on symfony/http-client. For unit tests, mock the bundle's interface; for integration tests, boot a minimal kernel so the DI extension actually runs — config bugs never surface in pure unit tests.

Straddling Laravel and Symfony. If you're in a mixed shop, the realistic pattern is: Laravel app calls a Symfony service that uses this bundle over HTTP, or vice versa. Keep the boundary at HTTP/JSON and don't try to share the bundle's DTOs across frameworks.

Gotchas and Tips

  • No Flex recipe. At this scale you almost certainly won't get auto-registration or auto-config. Add the bundle entry and config file by hand, and commit both.
  • Version pinning matters. Last release is 2025-06-26 with near-zero adoption — the API can move. Pin to a ^x.y in composer.json, and check the symfony/* constraints in the bundle's composer.json before upgrading your framework (composer why-not symfony/http-kernel ^7.2 is your diagnostic).
  • debug:config first, debug:container second. When a setting appears ignored, run php bin/console debug:config n7_http to confirm it's parsed, then debug:container to confirm it's injected. Nine times out of ten the YAML key is nested one level deeper than you assumed.
  • Cache is not optional. Symfony compiles the container. After touching bundle config or services.yaml, cache:clear (in dev, APP_ENV=dev typically auto-rebuilds, but stale prod caches are a classic).
  • Config quirks to expect: cannotBeEmpty() and requiresAtLeastOneElement() validators will fail hard at container compile time, not at runtime. If the container won't compile, the error message points at your YAML line — read it literally.
  • Extension points, in order of preference: (1) decorate a service, (2) tag-based listeners, (3) a compiler pass if you need to mutate many definitions at once:
    $container->registerForAutoconfiguration(SomeInterface::class)
        ->addTag('n7_http.handler');
    
  • Debugging HTTP specifics: enable the Symfony Profiler's HTTP client panel in dev; it shows every request the bundle makes, headers, and timings. If the bundle hides exceptions behind a custom exception type, check debug.exception_listener output via php bin/console debug:event-dispatcher kernel.exception to see whether it swallows errors.
  • Low adoption = you are the docs. With 0 dependents, don't expect Stack Overflow answers. Keep a short docs/n7-http.md in your repo recording the config you actually use and why. Read the bundle's source before opening an issue — that's usually faster than waiting on the maintainer.
  • License is MIT, so forking is legitimate if you hit a wall. A fork with a pin (via Composer's VCS repository entry) is often a cleaner escape hatch than a runtime hack.
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.
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource
noith/settings