symfony/proxy-manager-bridge
Symfony bridge for ProxyManager that generates virtual proxies and lazy-loading services. Integrates proxy creation with the Symfony DependencyInjection container to improve performance and enable on-demand instantiation of expensive services.
ProxyTrait).| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Proxy Generation Overhead | Medium | Benchmark proxy creation time in CI/CD. |
| Symfony Version Lock | High | Pin compatible Symfony versions in composer.json. |
| Memory Leaks | Medium | Monitor proxy lifecycle (e.g., Doctrine’s proxy cleanup). |
| Debugging Complexity | Medium | Use ProxyManager\Configuration for explicit proxy definitions. |
| Circular Dependencies | Low | Leverage Symfony’s autowire and private services. |
ProxyTrait or ProxyInterface suffice?ProxyTrait or PHP 8’s Attribute system replace ProxyManager?ProxyTrait with ProxyManager for advanced proxy logic.| Component | ProxyManager v2 | ProxyManager v3 | Symfony 6.x | Symfony 7.x |
|---|---|---|---|---|
| Doctrine ORM | ✅ | ✅ | ✅ | ✅ |
| HttpClient | ✅ | ✅ | ✅ | ✅ |
| EventDispatcher | ✅ | ✅ | ✅ | ✅ |
| DependencyInjection | ✅ | ✅ | ✅ | ✅ |
ProxyTrait.config/packages/proxy_manager.yaml:
proxy_manager:
enabled: true
proxies:
App\Entity\User: ~ # Auto-proxy Doctrine entity
App\Service\Logger: { methods: ['log'] } # Intercept specific methods
composer require hacks).ProxyQuery).ProxyInterface support).ProxyTrait for the same class.composer.json:
"require": {
"symfony/proxy-manager-bridge": "^3.0",
"proxy-manager/php-proxy-manager": "^3.0"
}
composer update.config/bundles.php:
return [
// ...
Symfony\ProxyManagerBridge\ProxyManagerBridge::class => ['all' => true],
];
services:
App\Service\MyService:
tags: ['proxy_manager.proxy']
ProxyManager\Factory\ProxyFactory).ProxyInterface deprecations).composer why-not symfony/proxy-manager-bridge:^3.0 to check compatibility.$proxyManager->setDebug(true);
proxy_manager:
debug: true
logger: monolog.logger.proxy
ProxyManager\Configuration for correct class mappings.php bin/console cache:clear
symfony/proxy-manager-bridge for known bugs.ProxyManager\GeneratorStrategy\FileGenerator for caching).memory_get_usage().opcache.jit_buffer_size=100M
ProxyManager\GeneratorStrategy\EvaluatingGenerator for dynamic proxies.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Proxy generation fails | App crashes on service init | Fallback to ProxyTrait or disable proxies. |
| Memory leak in proxies | High RAM usage over time | Use ProxyManager\Configuration to limit proxy lifetime. |
| Symfony cache corruption | Proxies not loaded | Clear cache and restart PHP-FPM. |
| ProxyManager version conflict | Runtime errors | Pin versions in composer.json. |
| Circular proxy references | Infinite recursion | Use ProxyManager\Proxy\LazyLoadingInterface. |
How can I help you explore Laravel packages today?