PHPackages                             addvilz/autoload\_patcher - 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. addvilz/autoload\_patcher

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

addvilz/autoload\_patcher
=========================

Patch any class file before autoloading it

v1.0.0(10y ago)21.7kApache-2.0PHP

Since Feb 10Pushed 10y agoCompare

[ Source](https://github.com/Addvilz/autoload_patcher)[ Packagist](https://packagist.org/packages/addvilz/autoload_patcher)[ RSS](/packages/addvilz-autoload-patcher/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Addvilz/autoload\_patcher
=========================

[](#addvilzautoload_patcher)

Purpose of this library
-----------------------

[](#purpose-of-this-library)

Purpose of this library is to allow patching the source code of class files during runtime.

There are some cases when you need to modify functionality of vendor code but you are not able to replace the code, or extend it (static calls from other vendor code is a good example).

This library allows you to replace, augment or otherwise change original source code and eval it afterwards.

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

[](#installation)

`composer require addvilz/autoload_patcher`

Example use:
------------

[](#example-use)

```
$loader = require 'vendor/autoload.php';
$patcher = new \Addvilz\AutoloadPatcher\Patcher($loader);
$patcher
    ->register()
    ->addPatcher('Some\Vendor\UtilityClass', function ($code) {

        // Let's rename the class
        $code = str_replace(
            'class UtilityClass',
            'class VendorUtilityClass',
            $code
        );

        // ... More modification here, runtime code generation, etc.

        return $code;
    });
```

How does it work?
-----------------

[](#how-does-it-work)

`Patcher->register()` method call appends an autoload callback to autoload stack. This means, all class loading will be proxied tru `Patcher` instance, and if patcher callback for given class is registered, it will be executed against source code from file determined by Composer `ClassLoader` class.

NB: Before the source code of the class is passed to the callback function, opening PHP tags are removed!

NB: Whatever the patcher callback function returns is passed on to `eval()`.

License
-------

[](#license)

Licensed under terms and conditions of Apache 2.0 license.

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

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

Unknown

Total

1

Last Release

3793d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/109aac4de31cd0ed15e840d5bd71cc57ed09aff1f69de81ee57a390d927a645e?d=identicon)[addvilz](/maintainers/addvilz)

---

Top Contributors

[![Addvilz](https://avatars.githubusercontent.com/u/1390347?v=4)](https://github.com/Addvilz "Addvilz (1 commits)")

### Embed Badge

![Health badge](/badges/addvilz-autoload-patcher/health.svg)

```
[![Health](https://phpackages.com/badges/addvilz-autoload-patcher/health.svg)](https://phpackages.com/packages/addvilz-autoload-patcher)
```

###  Alternatives

[digital-creative/icon-action-toolbar

Allows you to update a single column of a resource all at once.

2627.7k](/packages/digital-creative-icon-action-toolbar)

PHPackages © 2026

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