PHPackages                             fer-projekt/laravel-proxy - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. fer-projekt/laravel-proxy

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

fer-projekt/laravel-proxy
=========================

Laravel proxy trait to resolve the currently bound values of the given contract.

02.1kPHP

Since Oct 25Pushed 2y ago2 watchersCompare

[ Source](https://github.com/fer-projekt/laravel-proxy)[ Packagist](https://packagist.org/packages/fer-projekt/laravel-proxy)[ RSS](/packages/fer-projekt-laravel-proxy/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Proxy
=============

[](#laravel-proxy)

Laravel proxy trait to resolve the currently bound values of the given contract.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require fer-projekt/laravel-proxy
```

Usage
-----

[](#usage)

Easily swap container bindings without touching anything else in the codebase.

```
namespace App\Models;

use Ecommerce\Models\Product as BaseProduct;

class Product extends BaseProduct
{
    //
}
```

After you created your customizable model, you can swap the container binding for the product contract. You might do that in one of your service provider's `register` method:

```
use App\Models\Product;
use Ecommerce\Contracts\Product as Contract;

public function register()
{
    $this->app->bind(Contract::class, Product::class);
}
```

> Note, you should extend the **base model** then bind it to the **interface**.

Proxies
-------

[](#proxies)

Proxies are representing the classes that are currently bound to the container. You usually won't use these a lot, but in some cases – like when you develop a package or extension – proxies can be convenient.

```
use Ecommerce\Models\Product;

// Available proxy methods
Product::proxy();
Product::getProxiedClass();
Product::getProxiedContract();

// Proxied calls to the bound instance
Product::proxy()->newQuery()->where(...);
Product::proxy()->variation(...);

// Dynamic usage of bound classes
public function product()
{
    $this->belongsTo(Product::getProxiedClass());
}
```

Laravel Proxy provides the `InteractsWithProxy` trait, that makes the desired class proxyable. The trait comes with an abstract methods to be able to resolve the proxies class from the container automatically:

```
namespace App\Models;

use App\Contracts\Models\Addon as Contract;
use FerProjekt\LaravelProxy\InteractsWithProxy;
use Illuminate\Databse\Eloquent\Model;

class Addon extends Model implements Contract
{
    use InteractsWithProxy;

    /**
     * Get the proxied interface.
     *
     * @return string
     */
    public static function getProxiedInterface(): string
    {
        return Contract::class;
    }
}
```

Also, we need to bind the contract to the container in a service provider:

```
public function register(): void
{
    $this->app->bind(\App\Contracts\Models\Addon::class, \App\Models\Addon::class);
}
```

From this point, our `Addon` model is proxyable, which means if we swap the binding in the container, the proxied class will be the currently bound value and not the original one. This adds more flexibility when extending our application or using packages.

```
// Use the Addon proxy

Addon::proxy()->newQuery();
```

Development
-----------

[](#development)

Clone the package from the github:

```
git clone https://github.com/fer-projekt/laravel-proxy.git

cd laravel-proxy
```

Starting &amp; stopping docker

```
docker-compose up -d
```

```
docker-compose down
```

Install dependencies via composer and testing:

```
docker-compose exec app bash
```

```
composer update
```

```
phpunit
```

Credits
-------

[](#credits)

- [conedevelopment](https://github.com/conedevelopment)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity20

Early-stage or recently created project

 Bus Factor1

Top contributor holds 75% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/947468484993addb2d342572c56f39461a634b4c8b112e77284903e806dad66e?d=identicon)[fer-plus](/maintainers/fer-plus)

---

Top Contributors

[![arsydb](https://avatars.githubusercontent.com/u/6696018?v=4)](https://github.com/arsydb "arsydb (3 commits)")[![fer-plus](https://avatars.githubusercontent.com/u/48069280?v=4)](https://github.com/fer-plus "fer-plus (1 commits)")

### Embed Badge

![Health badge](/badges/fer-projekt-laravel-proxy/health.svg)

```
[![Health](https://phpackages.com/badges/fer-projekt-laravel-proxy/health.svg)](https://phpackages.com/packages/fer-projekt-laravel-proxy)
```

###  Alternatives

[ralouphie/mimey

PHP package for converting file extensions to MIME types and vice versa.

3285.9M72](/packages/ralouphie-mimey)[chencha/share

Share links with Laravel

182272.6k](/packages/chencha-share)[bocharsky-bw/arrayzy

A native PHP arrays easy manipulation library in OOP way.

38425.4k](/packages/bocharsky-bw-arrayzy)[mvanduijker/laravel-mercure-broadcaster

Mercure broadcaster

16866.5k](/packages/mvanduijker-laravel-mercure-broadcaster)[matomo/network

21897.4k4](/packages/matomo-network)[marc-mabe/php-enum-phpstan

Enum class reflection extension for PHPStan

13817.7k8](/packages/marc-mabe-php-enum-phpstan)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
