tourze/symfony-aop-cache-bundle
A Symfony bundle that adds AOP-driven caching to your services. Annotate methods with cache attributes and let the bundle handle cache keys, TTLs, and invalidation, keeping business logic clean and reducing repeated expensive calls.
Before reaching for this in a Laravel app, note the name: tourze/symfony-aop-cache-bundle is a Symfony bundle, not a Laravel package. There is no extra.laravel.providers auto-discovery, no service provider, and no facade. First step is to confirm it is even relevant to your stack — if you are on Laravel, treat this as a source of ideas (attribute-driven method caching via AOP) rather than a drop-in dependency.
If you are working inside Symfony (or a Laravel app that embeds Symfony components), the minimal path is:
composer require tourze/symfony-aop-cache-bundleTourze\Symfony\AopCacheBundle\AopCacheBundle in config/bundles.php.ray/aop-style proxying) — it wires a compiler pass that rewrites service definitions into proxy classes.var/cache/dev after the first request.First use case: caching an expensive, pure-ish service method (e.g. a repository lookup or an external API call) at the method level instead of hand-rolling Cache::remember() around every call site. The value proposition is declarative caching without touching call sites.
Because the release shipped only a changelog link (0.1.2...0.2.0) with no description of what changed, verify behavior against the actual composer diff / tag comparison before adopting — see Gotchas.
Declarative method caching. The intended workflow is to put the cache attribute on the service method and let the AOP proxy intercept invocations. Callers stay ignorant of caching; the proxy computes a key (typically class + method + serialized arguments), checks the cache pool, and either short-circuits or stores the result.
#[Cache(ttl: 300)]
public function findProduct(int $id): Product { /* ... */ }
Pool wiring. The bundle's compiler pass injects a Symfony cache pool into the generated proxy. In a Symfony app you configure the pool in config/packages/cache.yaml and the bundle picks up its configured service. This is the main integration seam — if the attribute appears to do nothing, check which pool the proxy received.
Key strategy. Arguments are serialized into the cache key, so patterns that work well are scalar-argument methods and DTOs with stable __toString/serialization. For methods with object arguments, either implement __serialize deterministically or bypass caching for those calls.
Layering with AOP. Because this is an AOP cache, it composes with other Tourze AOP aspects (logging, transactions, rate limiting). Ordering matters: caching typically wants to sit inside transaction/logging aspects but outside the actual business method. Audit aspect priority if you stack more than one attribute on a method.
Laravel bridging (if you must). You would need to (a) install the Symfony cache + DI + AOP packages, (b) build a bespoke ServiceProvider that boots the AOP kernel and registers proxy-compiled services, and (c) fight Laravel's container resolution, which does not understand Symfony compiled service definitions. In practice it is cheaper to replicate the pattern with a Laravel middleware/decorator or a simple Cache::remember trait than to bridge the bundle.
0.2.0 is still pre-1.0. Semver gives you no promise of backwards compatibility; a minor bump can rename attributes or change the proxy/compiler-pass contract. Pin the exact version and read the diff, not the changelog.0.1.2 → 0.2.0 as unknown risk: run composer update tourze/symfony-aop-cache-bundle --dry-run -v, diff the src/ tree, and check for renamed attributes or constructor-argument changes to the cache attribute before upgrading.opcache.validate_timestamps=0, regenerated proxies may not take effect until a PHP-FPM reload. Build proxies (or prime the cache) during deploy, not on the first request.config/aop-cache.php, no auto-discovery. Do not expect php artisan vendor:publish to produce anything. Every config quirk you hit has to be read from the bundle's DependencyInjection extension and Resources/config.Tourze\...) via the source — a wrong use statement fails silently when attributes are not resolvable.services.yaml rather than patching the bundle, so upgrades don't clobber your customization.How can I help you explore Laravel packages today?