<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/new-in-symfony-8-2-ratelimiter-improvements-symfony-blog--ubdncvrqe" -->

---
title: New in Symfony 8.2: RateLimiter Improvements (Symfony Blog)
description: Symfony 8.2 lets you create rate limiters at runtime and extends the #[RateLimit] attribute from 8.1. A new RateLimiterBuilder service offers slidingWindow(),...
canonical: https://daily.dev/posts/new-in-symfony-8-2-ratelimiter-improvements-symfony-blog--ubdncvrqe
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: New in Symfony 8.2: RateLimiter Improvements (Symfony Blog) | daily.dev
og:description: Symfony 8.2 lets you create rate limiters at runtime and extends the #[RateLimit] attribute from 8.1. A new RateLimiterBuilder service offers slidingWindow(),...
og:url: https://daily.dev/posts/new-in-symfony-8-2-ratelimiter-improvements-symfony-blog--ubdncvrqe
og:image: https://api.daily.dev/og/posts/ubDnCVRqE.png
og:image:alt: New in Symfony 8.2: RateLimiter Improvements (Symfony Blog)
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# New in Symfony 8.2: RateLimiter Improvements (Symfony Blog)

**[Symfony](https://daily.dev/sources/symfony)** · 6 min read · 0 upvotes · 0 comments

## Summary

Symfony 8.2 lets you create rate limiters at runtime and extends the #[RateLimit] attribute from 8.1. A new RateLimiterBuilder service offers slidingWindow(), fixedWindow(), tokenBucket(), compound() and noop(), useful when limits depend on a customer's plan. The attribute gains an exposeHeaders option for X-RateLimit-* headers, an if option taking a boolean, closure or expression, and a RateLimitExceededEvent dispatched before rejection. It also injects the consumed RateLimit as a controller argument. Tokens are now consumed once the controller is known, before argument resolvers run. This means they are consumed before #[IsGranted] checks too.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://symfony.com/blog/new-in-symfony-8-2-ratelimiter-improvements>

## Questions this post answers

### How do I create rate limiters at runtime in Symfony 8.2 when limits depend on the customer's plan?

Symfony 8.2 adds a RateLimiterBuilder service that creates limiter factories on the fly. It provides slidingWindow(), fixedWindow() and tokenBucket(), compound() to combine them, and noop() to disable limiting conditionally. The id argument is the storage namespace, so limiters created with the same id share their state. Results are RateLimiterFactoryInterface instances, used like configured limiters.

_Developers shipping Symfony upgrades follow changes like this on daily.dev._

### How do I add X-RateLimit headers to responses with Symfony's #[RateLimit] attribute?

Set the exposeHeaders option to true, as in #[RateLimit('api', exposeHeaders: true)]. Symfony 8.2 then adds X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset (a Unix timestamp) to both accepted and rejected responses. It is disabled by default because the headers reveal remaining attempts, so avoid it for login or password reset limiters.

_Anyone hardening Symfony APIs can keep up with these changes on daily.dev._

### Does Symfony 8.2 consume #[RateLimit] tokens before or after resolving controller arguments?

Symfony 8.2 consumes tokens as soon as the controller is known, so rejected requests skip costly value resolvers such as database entity loading. The exception is when the key or if option is a closure or expression using the args variable. A consequence is that early rate limits now run before attributes like #[IsGranted], whatever their order.

_Developers tracking Symfony behavior changes before upgrading will find them on daily.dev._

## Similar posts on daily.dev

- [New in Symfony 8.2: Locking Controllers \(Symfony Blog\)](https://daily.dev/posts/new-in-symfony-8-2-locking-controllers-symfony-blog--mkwvfc60j) · Symfony · 14 upvotes · 0 comments
- [New in Symfony 8.1: Dynamic Controller Attributes \(Symfony Blog\)](https://daily.dev/posts/new-in-symfony-8-1-dynamic-controller-attributes-symfony-blog--p1eaqpp8q) · Symfony · 4 upvotes · 0 comments
- [Upcoming changes in Rails rate limiter](https://daily.dev/posts/upcoming-changes-in-rails-rate-limiter-qncm9uboa) · RUBYLAND · 2 upvotes · 0 comments
- [Using native Rails rate-limits in production](https://daily.dev/posts/using-native-rails-rate-limits-in-production-ya70ybecx) · Ruby Flow · 0 upvotes · 0 comments

---

Tags: [#architecture](https://daily.dev/tags/architecture), [#php](https://daily.dev/tags/php), [#symfony](https://daily.dev/tags/symfony)

[View this post on daily.dev](https://daily.dev/posts/new-in-symfony-8-2-ratelimiter-improvements-symfony-blog--ubdncvrqe)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"New in Symfony 8.2: RateLimiter Improvements (Symfony Blog)","url":"https://daily.dev/posts/new-in-symfony-8-2-ratelimiter-improvements-symfony-blog--ubdncvrqe","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/new-in-symfony-8-2-ratelimiter-improvements-symfony-blog--ubdncvrqe"},"datePublished":"2026-11-27T16:20:36.029Z","dateModified":"2026-11-27T16:20:57.129Z","description":"Symfony 8.2 lets you create rate limiters at runtime and extends the #[RateLimit] attribute from 8.1. A new RateLimiterBuilder service offers slidingWindow(),...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/327b244859fddae8f3a20d0225898aa0?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/327b244859fddae8f3a20d0225898aa0?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Symfony","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Symfony","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/cc07051b7112472f9729e73c14660a64","url":"https://daily.dev/sources/symfony"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/new-in-symfony-8-2-ratelimiter-improvements-symfony-blog--ubdncvrqe","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"architecture,php,symfony","timeRequired":"PT6M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Symfony","item":"https://daily.dev/sources/symfony"},{"@type":"ListItem","position":3,"name":"New in Symfony 8.2: RateLimiter Improvements (Symfony Blog)"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/new-in-symfony-8-2-ratelimiter-improvements-symfony-blog--ubdncvrqe#faq","mainEntity":[{"@type":"Question","name":"How do I create rate limiters at runtime in Symfony 8.2 when limits depend on the customer's plan?","acceptedAnswer":{"@type":"Answer","text":"Symfony 8.2 adds a RateLimiterBuilder service that creates limiter factories on the fly. It provides slidingWindow(), fixedWindow() and tokenBucket(), compound() to combine them, and noop() to disable limiting conditionally. The id argument is the storage namespace, so limiters created with the same id share their state. Results are RateLimiterFactoryInterface instances, used like configured limiters. Developers shipping Symfony upgrades follow changes like this on daily.dev."}},{"@type":"Question","name":"How do I add X-RateLimit headers to responses with Symfony's #[RateLimit] attribute?","acceptedAnswer":{"@type":"Answer","text":"Set the exposeHeaders option to true, as in #[RateLimit('api', exposeHeaders: true)]. Symfony 8.2 then adds X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset (a Unix timestamp) to both accepted and rejected responses. It is disabled by default because the headers reveal remaining attempts, so avoid it for login or password reset limiters. Anyone hardening Symfony APIs can keep up with these changes on daily.dev."}},{"@type":"Question","name":"Does Symfony 8.2 consume #[RateLimit] tokens before or after resolving controller arguments?","acceptedAnswer":{"@type":"Answer","text":"Symfony 8.2 consumes tokens as soon as the controller is known, so rejected requests skip costly value resolvers such as database entity loading. The exception is when the key or if option is a closure or expression using the args variable. A consequence is that early rate limits now run before attributes like #[IsGranted], whatever their order. Developers tracking Symfony behavior changes before upgrading will find them on daily.dev."}}]}
```

