wernerdweight/cors-bundle
A Symfony bundle for adding Cross-Origin Resource Sharing (CORS) support to PHP applications. It helps configure allowed origins, headers, and methods so browsers can securely call your APIs and web endpoints, with setup handled through standard Symfony bundle configuration.
Headline finding: this is a Symfony bundle, not a Laravel package. wernerdweight/cors-bundle ships a Bundle subclass plus a dependency-injection extension, which is the Symfony kernel's registration contract. Laravel has no loader for Symfony bundles; it composes services through ServiceProvider classes and middleware registered on the HTTP kernel. Treating this as a Laravel dependency is a category error that any integration estimate must account for first.
Architecture fit. The package's job — injecting Access-Control-Allow-Origin, -Methods, -Headers, -Credentials, and answering OPTIONS preflights — is a genuinely cross-cutting HTTP concern, so it is architecturally adjacent to Laravel. But the delivery mechanism is wrong: it assumes Symfony's event dispatcher and container compilation pass. It will not auto-register, will not be discovered by Laravel's package discovery, and the service definitions will not resolve without an adapter. Any port is a rewrite against Laravel's Illuminate\Http\Middleware contract, not a configuration change.
Integration feasibility. Low, and largely unnecessary. Laravel has shipped first-party CORS handling (HandleCors middleware with a publishable config/cors.php) since 9.x, replacing the earlier fruitcake/laravel-cors dependency. A Laravel team adopting a 2-star Symfony bundle to solve a problem the framework already solves would be taking on bespoke code for zero functional gain. If the host application is actually Symfony, the realistic comparison is nelmio/NelmioCorsBundle, which is the de facto standard, is actively maintained, and has an order-of-magnitude larger user base.
Technical risk. High, concentrated in maintenance and correctness rather than in code volume. Last release was 2023-02-21; 2 stars and 0 dependents mean no downstream signal that anyone is exercising the code path. CORS is also a deceptively subtle spec surface: wildcard origin combined with credentials, Vary: Origin for cache correctness, Access-Control-Expose-Headers for non-safelisted response headers, correct short-circuiting of preflight without hitting routing/auth, and — most commonly missed — CORS headers on error and auth-rejection responses, not just 200s. A low-traffic bundle in this area is a plausible source of silent browser-only failures that unit tests and cURL checks routinely miss. Any adoption implies the team owns patching for PHP and framework version drift.
Key questions.
XDomainRequest-era behavior?Stack fit. Poor as a direct dependency. The realistic paths are three, in descending order of preference:
HandleCors plus config/cors.php, or NelmioCorsBundle on Symfony. Zero new dependencies, maintained upstream, documented.app/Http/Middleware, registered globally, roughly 40–80 lines. This is the correct fallback if the platform primitive is insufficient, and it eliminates the supply-chain and licensing-review questions entirely.Migration path. If the organization is on Laravel: publish config/cors.php, set paths to api/* and sanctum/csrf-cookie, define an explicit allowed_origins list rather than * where cookies are involved, and verify preflight and error-response behavior against a real browser. There is no migration from this package in a Laravel context because it was never wired in. If the organization is on Symfony and currently uses this bundle, the migration is to NelmioCorsBundle: both configure declaratively, and the mapping is close to one-to-one at the path/header level, so a contained change.
Compatibility. Composer constraints need checking against the current PHP and Symfony minor versions before any spike — a 2023 release is a likely mismatch with Symfony 7.x / PHP 8.3+. Laravel compatibility is effectively undefined and would require the adapter work above regardless of constraint resolution. Note also that the package is distributed as a bundle, so composer require alone will not surface a config file the way Laravel's publishable-config convention does.
Sequencing. (1) Confirm framework and the concrete CORS requirement. (2) Audit current preflight and error-path behavior in staging with a browser, not cURL. (3) Prefer the platform primitive; specify configuration as code and review it. (4) Only if that fails, build the thin in-house middleware behind a test suite covering preflight, credentials, error responses, and Vary. (5) Do not open a licensing/security review for this package unless steps 1–4 explicitly fail.
Maintenance. Effectively zero upstream velocity and a single-maintainer bus factor. In practice the team inherits ownership on day one: PHP version bumps, framework major upgrades, and any CORS spec-adjacent change become internal work. Against a 40-line alternative, the carrying cost of the dependency exceeds the cost of just writing it.
Support. No vendor, no SLAs, no active issue triage. Incidents will be diagnosed by whoever owns the middleware, which is fine — but that is an argument for owning the code outright rather than owning someone else's dormant code with a public API surface to respect.
Scaling. CORS header injection is O(1) per request and is not a throughput concern at any scale. The scaling risk is organizational: configuration drift across environments, and per-environment origin lists diverging between staging and production. This is a config-management problem, not a package-selection one, and it exists equally with the native middleware.
Failure modes to instrument and test for. Preflight returning 405/404 because the request never reaches the CORS layer (routing or auth runs first); headers absent on 4xx/5xx and auth-rejection responses; * combined with Allow-Credentials: true, which browsers reject outright; missing Vary: Origin causing a CDN or reverse proxy to serve one origin's response to another — the highest-severity failure here, because it is invisible in single-origin testing; over-long Access-Control-Max-Age freezing a stale policy; and Access-Control-Expose-Headers omissions that break client-side pagination or tracing headers. Each should have an explicit integration test. Notably, the CDN-caching failure mode is the one most likely to be introduced by whatever configuration is chosen, and least likely to be caught before production.
Ramp-up. Negligible in either direction — the package's conceptual surface is small and well understood by most backend engineers. The real ramp-up cost is the decision overhead of evaluating a dependency that the platform already obviates; the correct action is to close the evaluation quickly and redirect the effort into codifying and testing the origin policy.
Recommendation. Do not adopt. The stack mismatch, dormant maintenance, absent adoption signal, and existence of maintained first-party equivalents make this a clear pass. The 8.8 opportunity score likely reflects an underserved problem domain rather than a mature solution — which is an argument for writing the thin in-house middleware, not for taking on this dependency.
How can I help you explore Laravel packages today?