dealroadshow/proximity package implements a dynamic proxy pattern, enabling runtime interception of method calls, property access, and magic methods. This aligns well with:
__call, __get).UserRepository) or individual methods (e.g., find())?$app->bind(ProxiedUserRepository::class, function ($app) {
return Proximity::create(UserRepository::class, [
new LoggingInterceptor(),
new RetryInterceptor(),
]);
});
$client = Proximity::create(GuzzleClient::class, [
new RequestLoggingInterceptor(),
]);
class User extends Model {
public function getNameAttribute(): string {
return Proximity::create($this->name, [
new CachingInterceptor(),
]);
}
}
$stub = Proximity::create(UserRepository::class, [
new StubInterceptor(['find' => fn() => $fakeUser]),
]);
new Interceptor(function (Call $call) {
event(new MethodCalled($call->getTarget(), $call->getMethod()));
});
LoggerDecorator → LoggingInterceptor).bootstrap/app.php or a service provider.config/proximity.php.__callStatic or __invoke (rare in Laravel).opcache optimizations that bypass reflection.__call overrides).AppServiceProvider or dedicated ProximityServiceProvider.config/proximity.php or dedicated config class.dealroadshow/proximity for breaking changes (low activity; fork if needed).Proximity::enableDebug()).new RetryInterceptor(3, function (Throwable $e) {
Log::error("Proxy retry failed", ['exception' => $e]);
throw $e;
});
| Issue Type | Resolution Path |
|---|---|
| Proxy misconfiguration | Review interceptor definitions |
| Performance degradation | Profile with Xdebug, optimize interceptors |
| Reflection errors | Check proxied class method visibility |
| IDE autocompletion | Add PHPDoc annotations for proxied methods |
| Failure Scenario | Impact | Mitigation Strategy |
|---|---|---|
| Interceptor throws exception | Breaks proxied method chain | Wrap in try-catch or use fallback interceptor |
| Proxy generation fails | Unresolvable dependency | Validate proxied classes at runtime |
| Reflection security restrictions | Proxy fails silently | Whitelist allowed methods in interceptor |
| Memory leaks in interceptors | High memory usage | Use weak references for cached interceptors |
| IDE/tooling incompatibility | Poor developer experience |
How can I help you explore Laravel packages today?