PHPackages                             isra00/class-triggers - 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. isra00/class-triggers

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

isra00/class-triggers
=====================

Inject magic actions before and after any method of any class

76[1 issues](https://github.com/isra00/class-triggers/issues)PHP

Since Apr 29Pushed 8y ago1 watchersCompare

[ Source](https://github.com/isra00/class-triggers)[ Packagist](https://packagist.org/packages/isra00/class-triggers)[ RSS](/packages/isra00-class-triggers/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Inject logic to any method of any PHP class, dinamically
========================================================

[](#inject-logic-to-any-method-of-any-php-class-dinamically)

[![Build Status](https://camo.githubusercontent.com/91b16872cc0cfe28f1a9452dbf6642217245429596248893e2fd304df0a95f4e/68747470733a2f2f7472617669732d63692e6f72672f6973726130302f636c6173732d74726967676572732e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/isra00/class-triggers)

Partial and experimental implementation of Aspect-Oriented Programming. It gives you the ability to capture and manipulate the inputs, outputs and execution of any method of any class in PHP.

Basic usage
-----------

[](#basic-usage)

```
$a = new AnyClass;
$a = new ClassTriggers($a);

$a->bind($targetMethod, $trigger, function($arguments) {
	//Injected logic.
});

```

Example
-------

[](#example)

```
use ClassTriggers\ClassTriggers;

class Car
{
	private $position = 0;

	public function forward($increment)
	{
		$this->position += $increment;
	}

	public function getPosition()
	{
		return $this->position;
	}
}

$interceptedCar = new ClassTriggers(new Car);

$interceptedCar->bind('forward', 'preMethod', function(&$arguments) {
	echo 'You have requested forward(' . $arguments[0] . ")\n";

	if ($this->position + $arguments[0] > 10) {
		echo "Can't forward more than 10. Stopping method execution.\n";
		return ClassTriggers::COND_STOP_EXECUTION;
	}
});

```

Requiremens
-----------

[](#requiremens)

- PHP 5.4
- Composer

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

[](#installation)

You can install it via Composer, and use it instantly thanks to the Composer autoloader:

```
"require": {
	"isra00/class-triggers": "dev-master"
}

```

More info
---------

[](#more-info)

I wrote a tutorial in Spanish:

If you have any comments, ideas, questions... don't hesitate to raise an issue in GitHub :-)

Contributing
------------

[](#contributing)

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 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/4ffeea6fb3e3b481b968d74f18bcc467fd4aa960bfdc56627e25dac9b12db491?d=identicon)[isra00](/maintainers/isra00)

---

Top Contributors

[![isra00](https://avatars.githubusercontent.com/u/94328?v=4)](https://github.com/isra00 "isra00 (17 commits)")

### Embed Badge

![Health badge](/badges/isra00-class-triggers/health.svg)

```
[![Health](https://phpackages.com/badges/isra00-class-triggers/health.svg)](https://phpackages.com/packages/isra00-class-triggers)
```

PHPackages © 2026

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