ejsmont-artur/php-proxy-builder-bundle
php-proxy-builder library (if standalone) could be adapted for Laravel via Laravel’s Service Container or AOP frameworks (e.g., go-aop, hyperf/aop). However, the Bundle structure (Symfony-specific) introduces friction.app()->make() already supports lazy loading.go-aop/opinionated-aop or hyperf/aop (if migrating to Hyperf).Illuminate\Contracts\Container\BindingResolutionException handling).php-proxy-builder logic, but Symfony’s ContainerAware and EventDispatcher would need polyfills.php-proxy-builder (if extractable) could work in Laravel via:
// Hypothetical Laravel integration
$proxyBuilder = new \PhpProxyBuilder\ProxyBuilder();
$proxy = $proxyBuilder->buildProxy(new MyService(), [
'methodCall' => function ($method, $args) {
// Intercept logic here
}
]);
$container->bind('my.service', fn() => $proxy);
Closure-based bindings or Illuminate\Contracts\Container\ContextualBindingBuilder.| Risk Area | Assessment | Mitigation Strategy |
|---|---|---|
| Symfony Dependency | Bundle assumes Symfony’s DI/Events; Laravel lacks native equivalents. | Abstract core php-proxy-builder logic; polyfill Symfony dependencies. |
| Performance Overhead | Dynamic proxy generation may add latency if overused. | Benchmark proxy creation vs. decorator pattern; use sparingly for critical paths. |
| Maintenance Burden | Low-star, unmaintained package risks compatibility issues. | Fork and maintain; prefer Laravel-native solutions (decorators/AOP libraries). |
| Debugging Complexity | Proxies obscure call stacks, complicating error tracing. | Use Xdebug + proxy logging; avoid proxies for simple use cases. |
| Laravel Ecosystem Fit | Laravel’s DI container already solves 80% of proxy use cases natively. | Evaluate if the package solves a unique problem not covered by decorators/AOP. |
go-aop or Laravel’s built-in proxies achieve the same goals with less friction?| Laravel Component | Compatibility Notes |
|---|---|
| Service Container | Can bind proxies as singletons/closures; requires manual proxy generation. |
| Dependency Injection | Proxies can replace concrete bindings, but DI container won’t auto-generate them. |
| Events | Laravel’s event system can trigger proxy logic, but lacks Symfony’s EventDispatcher integration. |
| Facades/Helpers | Proxies can wrap facades, but may complicate testing. |
| AOP Alternatives | go-aop or hyperf/aop may offer better Laravel-native AOP support. |
Assess Core Needs
go-aop for aspect-oriented cross-cutting).Option 1: Lightweight Integration (Low Risk)
php-proxy-builder from the Symfony bundle.// app/Providers/ProxyServiceProvider.php
public function register() {
$this->app->singleton(MyService::class, function () {
$builder = new \PhpProxyBuilder\ProxyBuilder();
return $builder->buildProxy(new MyService(), [
'logMethodCall' => function ($method, $args) {
Log::info("Called {$method} with " . json_encode($args));
}
]);
});
}
Option 2: Full Bundle Port (High Risk)
ContainerAware with Laravel’s Container.EventDispatcher with Laravel’s Events.ServiceProvider instead of Bundle.Option 3: Use Alternatives
$this->app->when(MyService::class)
->needs('$decorated')
->give(fn($c) => new MyServiceDecorator($c->make(MyService::class)));
go-aop/opinionated-aop for aspect-oriented concerns:
// config/aop.php
'aspects' => [
MyAspect::class => [
'pointcuts' => [
'@annotation(MyCacheable)'
]
]
];
app/config/config.yml; Laravel uses config/proxy.php.EventDispatcher integrates with proxies; Laravel’s Events would need manual bridging.Annotation component, replace with Laravel’s Doctrine/Annotations or phpDocumentor/reflection-docblock.laravel-shift/mixins) for dynamic method injection.Phase 1: Proof of Concept (1-2 Days)
php-proxy-builder core logic.UserRepository).Phase 2: Integration (3-5 Days)
Phase 3: Validation (1 Week)
How can I help you explore Laravel packages today?