PHPackages                             inspira/augmentable - 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. inspira/augmentable

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

inspira/augmentable
===================

Augment PHP class at runtime.

032PHP

Since Feb 8Pushed 2y ago1 watchersCompare

[ Source](https://github.com/nadlambino/php-augmentable)[ Packagist](https://packagist.org/packages/inspira/augmentable)[ RSS](/packages/inspira-augmentable/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

Augmentable Trait
=================

[](#augmentable-trait)

The `Augmentable` trait allows for the dynamic addition of methods to a class.

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

[](#installation)

Install the `Augmentable` trait using composer:

```
composer require -s dev inspira/augmentable
```

Usage
-----

[](#usage)

### Basic Example

[](#basic-example)

```
use Inspira\Augmentable\Augmentable;

class ExampleClass {
    use Augmentable;
}

// Dynamically add a new method named 'customMethod'
ExampleClass::augment('customMethod', function () {
    return 'Custom method implementation';
});

// Use the dynamically added method
$instance = new ExampleClass();
$result = $instance->customMethod(); // Outputs: 'Custom method implementation'
```

### Checking for Dynamic Methods

[](#checking-for-dynamic-methods)

```
use Inspira\Augmentable\Augmentable;

class ExampleClass {
    use Augmentable;
}

// Check if a dynamic method named 'customMethod' exists
if (ExampleClass::augmented('customMethod')) {
    $instance = new ExampleClass();
    $result = $instance->customMethod(); // Call the method if it exists
} else {
    // Handle the case when the dynamic method does not exist
    echo 'Dynamic method does not exist.';
}
```

### Listing All Dynamic Methods

[](#listing-all-dynamic-methods)

```
use Inspira\Augmentable\Augmentable;

class ExampleClass {
    use Augmentable;
}

// Get an array of all dynamically added methods
$dynamicMethods = ExampleClass::augments();
print_r($dynamicMethods);
```

### Deaugment Added Method

[](#deaugment-added-method)

```
use Inspira\Augmentable\Augmentable;

class ExampleClass {
    use Augmentable;
}

// Dynamically add a new method named 'customMethod'
ExampleClass::augment('customMethod', function () {
    return 'Custom method implementation';
});

// Remove the 'customMethod'
ExampleClass::deaugment('customMethod');

// Remove all methods
ExampleClass::deaugment();
```

###  Health Score

14

—

LowBetter than 2% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity21

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/c2b2938add7fe0c000deb7f15e9259c27039409e918783b4a7cf2b9b4e3f35d0?d=identicon)[nadlambino](/maintainers/nadlambino)

---

Top Contributors

[![nadlambino](https://avatars.githubusercontent.com/u/50892397?v=4)](https://github.com/nadlambino "nadlambino (10 commits)")

### Embed Badge

![Health badge](/badges/inspira-augmentable/health.svg)

```
[![Health](https://phpackages.com/badges/inspira-augmentable/health.svg)](https://phpackages.com/packages/inspira-augmentable)
```

###  Alternatives

[adigital/help-links

Define useful links to be added to the dashboard for clients.

102.0k](/packages/adigital-help-links)[burnbright/silverstripe-bootstrap

Boilerplate theme, using bootstrap

101.0k](/packages/burnbright-silverstripe-bootstrap)

PHPackages © 2026

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