PHPackages                             simplemediacode/hooks - 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. simplemediacode/hooks

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

simplemediacode/hooks
=====================

Modern PHP Hooks System for PHP applications.

2.1.2(1y ago)23581GPL-2.0-onlyPHPPHP ~8.0|~8.1|~8.2|~8.3|~8.4

Since Dec 28Pushed 1y ago1 watchersCompare

[ Source](https://github.com/simplemediacode/hooks)[ Packagist](https://packagist.org/packages/simplemediacode/hooks)[ RSS](/packages/simplemediacode-hooks/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (10)DependenciesVersions (15)Used By (0)

Modern PHP Hooks System
=======================

[](#modern-php-hooks-system)

A lightweight, dependency-free implementation of an action and filter hook system inspired by WordPress hooks but designed for modern PHP applications.

Features
--------

[](#features)

- **Modern PHP Support**: Fully typed, supports PHP 8.0+
- **Dependency Injection Ready**: Use the `HooksInterface` in your classes
- **Static Facade**: Convenient static methods for quick integration
- **No Dependencies**: Lightweight implementation with zero dependencies
- **WordPress Inspired**: Familiar API if you're coming from WordPress

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

[](#installation)

Via **composer**:

```
composer require simplemediacode/hooks
```

Usage
-----

[](#usage)

### Using the Static Facade

[](#using-the-static-facade)

```
use Simplemediacode\Hooks\Hooks;

// Add a filter
Hooks::addFilter('content', function($content) {
    return strtoupper($content);
});

// Apply a filter
$content = Hooks::applyFilters('content', 'Hello World'); // Returns "HELLO WORLD"

// Add an action
Hooks::addAction('save_post', function($postId) {
    // Do something when a post is saved
    echo "Post {$postId} was saved!";
});

// Execute an action
Hooks::doAction('save_post', 123);
```

### Using Dependency Injection

[](#using-dependency-injection)

```
use Simplemediacode\Hooks\HooksInterface;

class MyClass
{
    private ?HooksInterface $hooks;

    public function __construct(
        ?HooksInterface $hooks = null
    ) {
        $this->hooks = $hooks;
    }

    public function processContent(string $content): string
    {
        // If hooks are available, filter the content
        if ($this->hooks) {
            $content = $this->hooks->executeHook('content', $content);
        }

        return $content;
    }
}
```

### Extending with Custom Implementations

[](#extending-with-custom-implementations)

You can implement your own version of `HooksInterface` to provide custom hook functionality:

```
$customHooks = new MyCustomHooksImplementation();
Hooks::setInstance($customHooks);
```

Migration from WP\_Hook
-----------------------

[](#migration-from-wp_hook)

This package is a complete rewrite of the original WordPress hook system. Key differences:

- Renamed `WP_Hook` to `Hook`
- Introduced proper interfaces for better type safety
- Added dependency injection support
- Replaced global variables with proper class properties
- Improved naming conventions and method signatures

Changelog
---------

[](#changelog)

Read at [CHANGELOG.md](./CHANGELOG.md).

License
-------

[](#license)

This library is released under the GPL-2.0 license. See the complete license in the bundled [LICENSE](./LICENSE) file.

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance46

Moderate activity, may be stable

Popularity19

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity78

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

Every ~141 days

Recently: every ~25 days

Total

12

Last Release

410d ago

Major Versions

1.0.8 → 2.0.02025-03-31

PHP version history (3 changes)1.0.1PHP ~7.4|~8.0

1.0.6PHP ~8.0|~8.1|~8.2

1.0.8PHP ~8.0|~8.1|~8.2|~8.3|~8.4

### Community

Maintainers

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

---

Top Contributors

[![rolandinsh](https://avatars.githubusercontent.com/u/108597?v=4)](https://github.com/rolandinsh "rolandinsh (39 commits)")

---

Tags

composercomposer-packagehookhook-functionshookinghooking-libraryhookshooks-apiphpphp8wordpresswordpress-actionswordpress-developmentwordpress-filterswordpress-php-libraryphpwordpresshooksPHP7php8phphookphphooks

### Embed Badge

![Health badge](/badges/simplemediacode-hooks/health.svg)

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

###  Alternatives

[wcm/git-php-hooks-library

A collection of Git PHP Hooks

1210.1k3](/packages/wcm-git-php-hooks-library)[x-wp/di

The dependency injection container for WordPress

301.1k10](/packages/x-wp-di)

PHPackages © 2026

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