medelse/referer-cookie-bundle
A Symfony bundle that captures the HTTP referer in a cookie, making referral information persist across requests for attribution, redirects, or analytics.
What it is: A Symfony bundle (*Bundle naming, DI extension + service wiring) that reads the inbound Referer header and persists it to a first-party cookie — a lightweight referrer/attribution capture mechanism. It is not a Laravel package, which is the first and most consequential finding.
Architecture fit: Poor for a Laravel stack. Bundles rely on Symfony's Bundle class, DependencyInjection\Extension, service tagging, and the HTTP kernel event system. Laravel boots service providers, not bundles. Adopting this would mean either (a) standing up a Symfony kernel alongside Laravel to host it — unjustifiable for a cookie write, or (b) rewriting it as a Laravel middleware + config file, at which point you are not adopting the package at all. If the organization is genuinely on Symfony, the architecture fit is fine but the adoption case is still weak (see risk below).
Integration feasibility: High only in the "copy the logic" sense. The functional surface is small and well-understood: inspect Referer, exclude same-host referrers, optionally honour an allowlist/blocklist, write a cookie with configured name, TTL, domain, path, Secure/SameSite. A competent PHP developer can reproduce this in Laravel in roughly 1–2 engineering days including config, tests, and consent gating. That is cheaper than the diligence required to trust an unmaintained third-party here.
Technical risk (high):
services.yaml conventions, and deprecations have moved materially since 2021. Likely to install but break at container compile time or on deprecated event names.Referrer-Policy: strict-origin-when-cross-origin, so you will generally receive origin only — no path, no query string. Any product requirement expecting full landing-page attribution will be silently unmet. Cross-site cookie restrictions and ITP/ETP also cap first-party cookie lifetimes in some contexts.Key questions for the requester:
Recommendation: Treat as a reference implementation, not a dependency. Score 0 is the correct read. Reproduce the behaviour natively, with attribution to the MIT-licensed original if code is copied.
Stack fit: If Laravel — no direct fit; implement as a global or web-group middleware with a config/referrer-cookie.php and an entry in the service container. If Symfony — technically installable via Composer, but pin to a commit and fork into a private VCS (GitHub/Packagist mirror) before use, since upstream is dormant.
Migration path: There is nothing to migrate from — no dependents, no installs. The practical path is greenfield:
Secure/SameSite correctness.Compatibility considerations:
SameSite=Lax by default; None requires Secure and should not be used for a first-party attribution cookie.Sequencing: Legal/privacy sign-off → behaviour spike → reimplementation → contract tests → feature flag → canary → full rollout. Do not sequence the privacy review after launch; retrofitting consent onto an already-set cookie is a cleanup exercise with legal exposure.
Effort estimate: 3–4 engineering days total including tests and review. Far below the cost of vendor diligence, fork maintenance, and future Symfony-upgrade compatibility work.
Maintenance: Effectively zero upstream maintenance. Because you will own the code either way, the only question is whether you own a private fork of someone else's bundle or 150 lines of your own middleware. The latter is cheaper to reason about, upgrade, and delete.
Support: None. No SLA, no maintainer responsiveness, no security advisory channel. Any incident — a bad cookie domain breaking attribution, a Set-Cookie conflict with a session cookie — is yours to diagnose with no upstream backstop.
Scaling: Negligible performance cost — one header read and one Set-Cookie per request. The real scaling concern is caching: if responses are served from a CDN, Varnish, or full-page cache, the Set-Cookie header may be stripped or the cached response served without it, and attribution silently disappears for the majority of traffic. This must be designed for explicitly (bypass cache on the referrer path, or set the cookie client-side after a cache-safe API call). Cookie size also matters at scale — keep values short.
Failure modes to monitor:
Referrer-Policy, privacy extensions, or app-to-web transitions. Looks like "no traffic from that channel," not like an error.www. only, invisible on app. or apex; attribution breaks for a subset of the funnel.Ramp-up: Low. Any PHP developer can read and modify this in an hour. Documentation is minimal-to-absent, so budget time for the behaviour spike to establish ground truth rather than relying on the README.
Bottom line for the TPM: The cost of adopting this package exceeds the cost of replacing it. Approve the requirement if the attribution gap is real and unowned elsewhere; reject the dependency; fund 3–4 days of native implementation with privacy review as a hard gate.
How can I help you explore Laravel packages today?