Search by

jundayw / laravel-proxy-manager

jundayw

Proxy Manager integration for Laravel.

Package info

github.com/jundayw/laravel-proxy-manager

pkg:composer/jundayw/laravel-proxy-manager

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

dev-main / 1.x-dev 2026-10-08 02:46 UTC

This package is auto-updated.

Last update: 2026-10-08 02:47:25 UTC


README

Laravel Proxy Manager

Proxy Manager integration for Laravel — a lightweight, type-safe, inheritance-based extension that brings dynamic proxies and aspect-oriented programming (AOP) to Laravel. Define aspects once, and let proxies weave cross-cutting concerns like logging, caching, transactions, and authorization into your services — without touching business logic.

GitHub Tag Total Downloads Packagist Version Packagist PHP Version Support Packagist License

Table of Contents
  1. Installation
  2. Usage
  3. Contributing
  4. Contributors
  5. License

Installation

You can install the package via Composer:

composer require jundayw/laravel-proxy-manager

You can publish the config file with:

php artisan vendor:publish --provider="Jundayw\ProxyManager\ProxyManagerServiceProvider" --tag="config"

[back to top]

Quick Start

Just extend Jundayw\Proxy\Contracts\Proxy and add the Jundayw\Proxy\Attributes\Proxy middleware attribute.

<?php

use Jundayw\Proxy\Attributes\IgnoreProxy;
use Jundayw\Proxy\Attributes\Proxy;
use Jundayw\Proxy\Attributes\ProxyIgnore;
use Jundayw\Proxy\Contracts\Proxy as AOP;

#[Proxy([
    new TraceMiddleware(),
    new LoggingMiddleware(),
    new TimingMiddleware(),
])]
class OrderService implements AOP
{
    public function create(
        string $orderNo,
        int|float $amount,
    ): ?Order {
        // Business logic
    }

    public function find(
        int|string $id,
    ): ?Order {
        // Business logic
    }

    #[IgnoreProxy]
    public function healthCheck(): string
    {
        return 'ok';
    }

    #[ProxyIgnore]
    public function internalCalculation(
        int $amount,
    ): int {
        return $amount * 100;
    }
}

Built-in Attributes

#[Proxy]

#[Proxy] enables proxy generation and defines the middleware pipeline.

#[Proxy([
    new TraceMiddleware(),
    new LoggingMiddleware(),
    new TimingMiddleware(),
])]
class OrderService
{
}

Middleware is executed according to the configured pipeline.

#[IgnoreProxy]

Use #[IgnoreProxy] to exclude a method from proxy interception.

#[IgnoreProxy]
public function healthCheck(): string
{
    return 'ok';
}

Typical use cases include:

  • Health checks
  • Internal methods
  • Framework callbacks
  • Lightweight methods
  • Performance-sensitive methods

#[ProxyIgnore]

#[ProxyIgnore] provides method-level proxy exclusion.

#[ProxyIgnore]
public function internalCalculation(
    int $amount,
): int {
    return $amount * 100;
}

This makes proxy behavior explicit at the method level.

Middleware

Middleware is the primary extension point of Proxy Manager.

For example:

<?php

namespace App\Proxy\Middleware;

use Jundayw\Proxy\Contracts\Middleware;
use Jundayw\Proxy\Invocation;

class TimingMiddleware implements Middleware
{
    public function __invoke($request, Closure $next)
    {
        return $next($request);
    }
}

Middleware can be used for:

  • Logging
  • Tracing
  • Metrics
  • Authorization
  • Transactions
  • Caching
  • Idempotency
  • Auditing
  • Performance monitoring

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

[back to top]

Contributors

Thanks goes to these wonderful people:

contrib.rocks image

Contributions of any kind are welcome!

[back to top]

License

Distributed under the MIT License (MIT). Please see License File for more information.

[back to top]