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.
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:
composer require n7/symfony-http-bundleconfig/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.config/packages/n7_http.yaml matching the bundle's Configuration tree.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:
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.
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.
^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.services.yaml, cache:clear (in dev, APP_ENV=dev typically auto-rebuilds, but stale prod caches are a classic).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.$container->registerForAutoconfiguration(SomeInterface::class)
->addTag('n7_http.handler');
debug.exception_listener output via php bin/console debug:event-dispatcher kernel.exception to see whether it swallows errors.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.How can I help you explore Laravel packages today?