PHPackages                             borkness/phproxy - 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. borkness/phproxy

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

borkness/phproxy
================

Simple trait to allow static proxies similar to Laravel Facades

v1.0.0(5y ago)03MITPHP

Since Oct 6Pushed 5y ago1 watchersCompare

[ Source](https://github.com/Borkness/phproxy)[ Packagist](https://packagist.org/packages/borkness/phproxy)[ RSS](/packages/borkness-phproxy/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Phproxy
=======

[](#phproxy)

[![StyleCI](https://camo.githubusercontent.com/6ec33061403008d3b768b583b309e13a30593b499caf69350d86704d42cb4113/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3330313833363135342f736869656c643f6272616e63683d6d6173746572)](https://camo.githubusercontent.com/6ec33061403008d3b768b583b309e13a30593b499caf69350d86704d42cb4113/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3330313833363135342f736869656c643f6272616e63683d6d6173746572) [![Build Status](https://camo.githubusercontent.com/92817d6a89ed4a4ba211b220b73817783b32691f9b5f2e41bff37a331b317f86/68747470733a2f2f7472617669732d63692e6f72672f426f726b6e6573732f706870726f78792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Borkness/phproxy)

Phproxy is a class that can be used to statically call the methods of an underlying class similar to Facades in Laravel.

Usage
-----

[](#usage)

### Initial Setup

[](#initial-setup)

In order to use Phproxy you must implement a PSR-11 compatible container. Implementations you could use are:

- PHP-DI (Recommended)
- League Container
- Aura-DI

Once you have installed and created the container you need to call the `setInstanceResolver()` method passing in the container.

```
\Borkness\Phproxy\Phproxy::setInstanceResolver($container);
```

### Creating a proxy class

[](#creating-a-proxy-class)

To create a proxy class you will need to extend the Phproxy abstract class overriding the `getClassIdentifier()` method. You must add the string you used for the class when setting up the DI container.

##### Example:

[](#example)

```
