Symfony 8.2.0 was released on 28 November 2026. It is a regular (non-LTS) minor release, and according to the Symfony 8.2 release page data, it is maintained until July 2027. Over the past few weeks the Symfony team published a “New in Symfony 8.2” series covering improvements to Serializer, Doctrine, Messenger, HttpClient, Security, testing, the profiler and more.
Rather than repeat every item, this tutorial does two things. First, it shows a safe way to upgrade an 8.1 app to 8.2. Second, it digs into one area that affects almost every API: the RateLimiter improvements, which add runtime-built limiters and a much more capable #[RateLimit] attribute.
What landed in Symfony 8.2
The New in Symfony 8.2 series summarises the main areas:
- DependencyInjection: per-argument lazy proxies, methods declared as services, computed tag attributes and class maps.
- ObjectMapper: automatic backed enum conversion and nested targets inferred from property types.
- Security: users re-checked on every request, impersonation protected with POST and CSRF, guest permission checks and hiding which usernames exist.
- Profiler: reasons for skipped authenticators, HTTP client timings and sizes, and better accessibility.
- Messenger: a middleware attribute, typed buses, batch sending, transport cooldowns and an AMPHP SQL transport.
- HttpClient: cache policies, cacheable QUERY requests, retries against fallback base URIs and safer redirects.
- Testing: Messenger and Webhook assertions, logins on stateless firewalls and a single mocked clock.
- Doctrine: automatic entity discovery and DatePoint columns without an explicit type.
- Serializer: extendable discriminator maps, CSV column mapping and an option to skip invalid values.
The final release itself, compared with RC1, is mostly bug fixes. Two are worth calling out: a security fix that checks the binding and size of a DPoP proof key before verifying its signature, and an HttpClient fix for high CPU usage in AmpHttpClient with many concurrent streams. The full list is in the v8.2.0 release on GitHub.
Upgrading from Symfony 8.1 to 8.2
Minor Symfony upgrades are designed to be backward compatible, but you should still remove deprecations first. A reliable sequence:
1. Fix deprecations on 8.1
Run your test suite and check the deprecation report. With PHPUnit and the Symfony PHPUnit bridge, deprecations are listed at the end of the run. Fix them while you are still on 8.1. Deprecated code is only removed in the next major version, but the warnings show you which code paths are changing.
2. Bump the version constraint
In composer.json, update extra.symfony.require and every symfony/* package constraint from 8.1.* to 8.2.*:
{
"extra": {
"symfony": {
"require": "8.2.*"
}
}
}
Then update:
composer update "symfony/*" --with-all-dependencies
php bin/console cache:clear
php bin/console about
bin/console about should now report Symfony 8.2.0.
3. Check recipes and run tests
Run composer recipes to see whether any Flex recipe has updates, review the changes, and run your full test suite. The official upgrade guide covers the details for minor releases.
Rate limiting in Symfony 8.2
The RateLimiter component got some of the most practical changes in this release. All code below is taken from or based on the official Symfony blog post.
Build limiters at runtime with RateLimiterBuilder
Until now each limiter was defined under framework.rate_limiter and injected separately. That breaks down when limits depend on data, for example a customer’s subscription plan. Symfony 8.2 adds a RateLimiterBuilder service:
use Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException;
use Symfony\Component\RateLimiter\RateLimiterBuilder;
class ReportController extends AbstractController
{
public function export(RateLimiterBuilder $limiterBuilder): Response
{
$plan = $this->getUser()->getPlan();
$limiter = $limiterBuilder
->slidingWindow(
id: 'export_'.$plan->getName(),
limit: $plan->getExportsPerHour(),
interval: '1 hour',
)
->create($this->getUser()->getUserIdentifier());
if (!$limiter->consume()->isAccepted()) {
throw new TooManyRequestsHttpException();
}
// generate the export...
}
}
The builder offers slidingWindow(), fixedWindow(), tokenBucket(), compound() to combine several policies, and noop() to switch rate limiting off conditionally. The id is the storage namespace, so limiters built with the same id share state. That is why the example includes the plan name in it.
Tell clients their remaining quota
#[RateLimit] (introduced in 8.1) already sent Retry-After on rejections. The new exposeHeaders option adds X-RateLimit-* headers to accepted and rejected responses:
#[RateLimit('api', exposeHeaders: true)]
public function index(): JsonResponse { /* ... */ }
HTTP/1.1 200 OK
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 97
X-RateLimit-Reset: 1787403071
Responses with these headers are marked private, so shared caches never store one client’s counters. The option is off by default. Keep it off for sensitive limiters such as login or password reset, because it tells attackers exactly how many attempts they have left.
Different limits for guests and logged-in users
The new if option takes a boolean, a closure or an expression, and expressions can use security functions:
use Symfony\Component\ExpressionLanguage\Expression;
use Symfony\Component\HttpKernel\Attribute\RateLimit;
class ApiController extends AbstractController
{
#[RateLimit('anonymous_api', if: new Expression('!is_authenticated()'))]
#[RateLimit(
'user_api',
key: new Expression('current_user().getUserIdentifier()'),
if: new Expression('is_authenticated()'),
)]
public function index(): JsonResponse { /* ... */ }
}
When a condition is false, that attribute is skipped and no tokens are consumed. Make sure your conditions cover every request: a request that matches none of them is not rate limited at all. Also avoid conditions based on client-controlled data like custom headers, or clients could pick their own limiter.
Show the quota inside your response
Type-hint the RateLimiter component’s RateLimit class and Symfony injects the result the attribute just consumed, without consuming extra tokens:
use Symfony\Component\HttpKernel\Attribute\RateLimit;
use Symfony\Component\RateLimiter\RateLimit as ConsumedRateLimit;
#[RateLimit('api')]
public function index(ConsumedRateLimit $rateLimit): JsonResponse
{
return $this->json([
'quota' => [
'remaining' => $rateLimit->getRemainingTokens(),
'resets_at' => $rateLimit->getResetAt()?->format(\DATE_ATOM),
],
]);
}
If no attribute applies to a request (because of if or methods), make the argument nullable or give it a default, otherwise Symfony throws a LogicException.
Log abusive clients
The attribute now dispatches RateLimitExceededEvent just before rejecting a request. It is informational only, so you can log or count rejections but not change the response:
use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
use Symfony\Component\RateLimiter\Event\RateLimitExceededEvent;
final class RateLimitLogger
{
public function __construct(private LoggerInterface $logger) {}
#[AsEventListener]
public function onRateLimitExceeded(RateLimitExceededEvent $event): void
{
$this->logger->warning('Rate limit "{limiter}" exceeded for "{key}".', [
'limiter' => $event->getLimiterName(),
'key' => $event->getKey(),
]);
}
}
Watch out: limits now run earlier
#[RateLimit] now consumes tokens as soon as the controller is known, before argument resolvers run. Rejected requests no longer trigger expensive work like loading entities from the database. The exception is when key or if reads the args variable, because then arguments must be resolved first.
There is one side effect to check after upgrading: early rate limits now run before attributes like #[IsGranted], whatever order you wrote them in. Requests later denied by #[IsGranted] will have consumed tokens too. If your quotas are tight, review them.
Takeaway
Symfony 8.2 is a solid minor release with improvements across almost every component. Upgrade by clearing deprecations on 8.1, bumping constraints to 8.2.* and re-running your tests. Then look at rate limiting: RateLimiterBuilder, exposeHeaders, conditional limits and the injected RateLimit make plan-based API quotas much easier to build, as long as you remember that limits now run before #[IsGranted].
