genedys/csrf-route-bundle
A Laravel/PHP package for adding CSRF protection to routes, helping secure state-changing requests with token validation and straightforward route integration. Lightweight and simple to configure for safer forms and endpoints.
Architecture fit — still a fundamental mismatch; 3.0.0 does not change the category. This remains a Symfony bundle. Registration still runs through Symfony\Component\HttpKernel\Bundle\Bundle and a DependencyInjection extension, which Laravel's ServiceProvider lifecycle has no analogue for. Release 3.0.0 reduces internal coupling — CsrfRouter no longer extends the Symfony Router, CsrfTokenManager is removed with logic redistributed, PSR-0 → PSR-4, legacy Symfony <2.4 shims dropped — but none of that creates a composer.json extra.laravel block, facade, publishable config, middleware alias, or Blade directive. It cannot be composer required into a Laravel app and work. The refactor is a maintainability improvement for Symfony consumers, not an integration surface for us.
The value proposition still evaporates in Laravel. The bundle exists because Symfony's CSRF protection is form-centric and manual. Laravel already ships route-scoped CSRF via the web middleware group and VerifyCsrfToken, handling @csrf, X-CSRF-TOKEN, and _token. The gap this fills does not exist in the target stack. The 3.0.0 performance fix (removing getRouteCollection usage from the hot path) is the clearest evidence of this: that call is a Symfony router-collection pattern with no Laravel equivalent, because Laravel never had the problem being solved.
Integration feasibility — extract, don't install; the extraction target just moved. Porting the idea (route-scoped token intents) into Laravel primitives remains the only realistic path: a route macro + small middleware, or Crypt::encryptString() / URL::temporarySignedRoute() for stateless route-bound tokens. 1–2 day spike. Caveat introduced by 3.0.0: the logic that previously lived in CsrfTokenManager has been relocated across other classes, so any prior reference notes or draft port are now stale and must be re-read against the 3.0.0 tag, not master history.
Technical risk — high, and the release adds one new risk vector.
>=3.3 is still an EOL floor. No patches will arrive.symfony/* >= 3.3 and php >= 5.5.9 are open-ended. Composer may resolve modern Symfony 6/7 components or PHP 8.3 against code written and tested for Symfony 3.3–3.x. That converts "fails loudly on modern PHP" into "installs successfully, then validates permissively" — the dangerous failure mode for security code. Pin everything or don't install.Key questions to resolve before any decision:
VerifyCsrfToken does not cover (webhook ingress, stateless API, SPA split-domain)?csrf_token() + per-route intent?CsrfRouter usable standalone, and does the 3.0.0 perf change alter the token lifecycle or only the route lookup? Read the diff, don't trust the summary.Stack fit: poor to none, unchanged. Laravel 10/11 + this bundle has no supported path. If a legacy Symfony 3.x service is in scope, 3.0.0 is a net upgrade (PSR-4, perf, less legacy) but still sits on an EOL framework — migration risk dominates feature benefit.
Migration path — still "build," not "adopt":
Route::macro('csrfScoped', …) registering a named token intent plus matching middleware. Option B (preferred, stateless): URL::temporarySignedRoute() with route name and user ID in the payload — no session coupling, no server-side store. Reuse Laravel's Crypt (AES-256-GCM); do not port the bundle's token encoding.csrf_token() with a per-route intent, and plan off the bundle before the Symfony 4/5 upgrade. Design any custom scheme to be replaceable by StatelessCsrfTokenManager (Symfony 7).Compatibility: the Bundle subclass still will not register under Symfony 4+ without conversion to a Flex recipe/bundle-less structure. Note the 3.0.0 constraints are more permissive than before, not less: symfony/* >= 3.3 will happily resolve alongside Laravel's symfony/* ^6/^7 tree, so composer require may succeed and produce a class-loading or signature fatal at runtime rather than a clean why-not conflict. That is worse for us — the guardrail is now a review, not the resolver.
Sequencing:
3.0.0 tag and read the post-refactor code — the removed CsrfTokenManager invalidates earlier notes.Maintenance: velocity is now low but non-zero rather than zero — a correction to the prior assessment. That is the only operationally meaningful change in 3.0.0, and it does not move the decision. Adopting still means owning security-critical code permanently, plus the EOL Symfony 3 dependency chain. TCO for a ~40-line native Laravel feature remains heavily negative. The unbounded >= constraints mean the dependency graph can drift under you without any upstream commit — pinning is mandatory if anything is installed anywhere.
Support: no community to escalate to — 1 star, 0 dependents, no visible issue-tracker activity or security policy. A 3.0.0 that removes public classes with no deprecation path or upgrade guide signals the maintainer is not optimizing for downstream consumers. Internal engineers would still reverse-engineer a Symfony bundle to answer basic questions, and the 3.0.0 refactor has invalidated the prior mental map of where token logic lives — a knowledge-concentration risk if the engineer who reads it leaves.
Scaling: the mechanism is cheap. Cost is driven by token storage: session-backed tokens scale with the session store and add a round trip per request; stateless signed tokens scale trivially. Distinct token per route grows token count with route cardinality and open tabs per user — usually fine, occasionally a UX problem. Nothing in 3.0.0 changes this; the performance fix is a route-lookup optimization inside Symfony, not a scaling property we inherit.
Failure modes to plan for:
symfony/* >= 3.3 and php >= 5.5.9 allow resolution against untested major versions. Unmaintained code on modern PHP tends to either fatal loudly (acceptable) or validate permissively (unacceptable); only code review settles which, and the resolver will no longer protect you.CsrfTokenManager removed, CsrfRouter no longer extends Router. Budget a migration and regression-test the login flow.Ramp-up: high relative to payoff, marginally lower than before (PSR-4, less legacy code, fewer class/method descriptions to wade through — though that last one cuts both ways). Engineers need Symfony bundle literacy to evaluate the source, then Laravel expertise to port — two skill sets for a feature the framework already provides. Effective ramp-up cost is the cost of the reimplementation; the bundle is a reference design, and a reference that has moved since the last review.
Recommendation: Do not adopt. Unchanged. Treat the repository as a design reference at the 3.0.0 tag only, and close the requirement with a native Laravel implementation (signed route tokens or scoped middleware). The new release improves the artifact's internal hygiene and revives the maintenance signal, but the framework mismatch, the EOL toolchain, the absent test evidence, and now the unbounded constraints all still point the same direction.
How can I help you explore Laravel packages today?