PHPackages                             vedavith/liberator-fork - 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. vedavith/liberator-fork

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

vedavith/liberator-fork
=======================

A proxy for circumventing PHP access modifier restrictions.

v4.2.0(4mo ago)12.0kMITPHPPHP &gt;=8.2CI passing

Since Feb 9Pushed 4mo agoCompare

[ Source](https://github.com/vedavith/liberator-fork)[ Packagist](https://packagist.org/packages/vedavith/liberator-fork)[ Docs](https://github.com/vedavith/liberator-fork)[ RSS](/packages/vedavith-liberator-fork/feed)WikiDiscussions main Synced today

READMEChangelog (3)Dependencies (5)Versions (5)Used By (0)

Liberator
=========

[](#liberator)

*A proxy for circumventing PHP access modifier restrictions.*

> - This is a maintained fork of the unmaintained `eloquent/liberator`. Package name is `vedavith/liberator-fork` and it targets PHP 8.2+ with PHPUnit 11/12 for development.
> - This is a maintained fork of \[eloquent/liberator\] originally created by Erin Millard.

Installation and documentation
------------------------------

[](#installation-and-documentation)

- Available as [Composer](http://getcomposer.org/) package [vedavith/liberator-fork](https://packagist.org/packages/vedavith/liberator-fork): (maintained fork of `eloquent/liberator`).
- Requires PHP 8.2 or later.

```
  composer require vedavith/liberator-fork

```

What is Liberator?
------------------

[](#what-is-liberator)

*Liberator* allows access to **protected** and **private** methods and properties of objects as if they were marked **public**. It can do so for both objects and classes (i.e. static methods and properties).

*Liberator*'s primary use is as a testing tool, allowing direct access to methods that would otherwise require complicated test harnesses or mocking to test.

Usage
-----

[](#usage)

### For objects

[](#for-objects)

Take the following class:

```
class SeriousBusiness
{
    private function foo($adjective)
    {
        return 'foo is ' . $adjective;
    }

    private $bar = 'mind';
}
```

Normally there is no way to call `foo()` or access `$bar` from outside the `SeriousBusiness` class, but *Liberator* allows this to be achieved:

```
use Eloquent\Liberator\Liberator;

$object = new SeriousBusiness;
$liberator = Liberator::liberate($object);

echo $liberator->foo('not so private...'); // outputs 'foo is not so private...'
echo $liberator->bar . ' = blown';         // outputs 'mind = blown'
```

### For classes

[](#for-classes)

The same concept applies for static methods and properties:

```
class SeriousBusiness
{
    static private function baz($adjective)
    {
        return 'baz is ' . $adjective;
    }

    static private $qux = 'mind';
}
```

To access these, a *class liberator* must be used instead of an *object liberator*, but they operate in a similar manner:

```
use Eloquent\Liberator\Liberator;

$liberator = Liberator::liberateClass('SeriousBusiness');

echo $liberator->baz('not so private...'); // outputs 'baz is not so private...'
echo $liberator->qux . ' = blown';         // outputs 'mind = blown'
```

Alternatively, *Liberator* can generate a class that can be used statically:

```
use Eloquent\Liberator\Liberator;

$liberatorClass = Liberator::liberateClassStatic('SeriousBusiness');

echo $liberatorClass::baz('not so private...');      // outputs 'baz is not so private...'
echo $liberatorClass::liberator()->qux . ' = blown'; // outputs 'mind = blown'
```

Unfortunately, there is (currently) no \_\_getStatic() or \_\_setStatic() in PHP, so accessing static properties in this way is a not as elegant as it could be.

Applications for Liberator
--------------------------

[](#applications-for-liberator)

- Writing [white-box](http://en.wikipedia.org/wiki/White-box_testing) style unit tests (testing protected/private methods).
- Modifying behavior of poorly designed third-party libraries.

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance74

Regular maintenance activity

Popularity17

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 70% 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.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

145d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/18259805?v=4)[Vedavith Ravula](/maintainers/vedavith)[@vedavith](https://github.com/vedavith)

---

Top Contributors

[![ezzatron](https://avatars.githubusercontent.com/u/100152?v=4)](https://github.com/ezzatron "ezzatron (21 commits)")[![vedavith](https://avatars.githubusercontent.com/u/18259805?v=4)](https://github.com/vedavith "vedavith (9 commits)")

---

Tags

proxyreflectionobjectaccessmodifierprivateprotected

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/vedavith-liberator-fork/health.svg)

```
[![Health](https://phpackages.com/badges/vedavith-liberator-fork/health.svg)](https://phpackages.com/packages/vedavith-liberator-fork)
```

###  Alternatives

[symfony/property-access

Provides functions to read and write from/to an object or array using a simple string notation

2.8k317.3M3.2k](/packages/symfony-property-access)[myclabs/deep-copy

Create deep copies (clones) of your objects

8.9k894.3M227](/packages/myclabs-deep-copy)[phpdocumentor/reflection-common

Common reflection classes used by phpdocumentor to reflect the code structure

9.1k736.5M37](/packages/phpdocumentor-reflection-common)[fideloper/proxy

Set trusted proxies for Laravel

7.3k176.5M561](/packages/fideloper-proxy)[symfony/var-exporter

Provides tools to export, instantiate, hydrate, clone and lazy-load PHP objects

2.1k407.7M758](/packages/symfony-var-exporter)[friendsofphp/proxy-manager-lts

Adding support for a wider range of PHP versions to ocramius/proxy-manager

1.2k147.4M152](/packages/friendsofphp-proxy-manager-lts)

PHPackages © 2026

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