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

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

getpop/hooks
============

Contracts to implement hooks (filters and actions) for PoP

0.8.9(4y ago)113.7k13GPL-2.0-or-laterPHPPHP ^8.0

Since May 3Pushed 4y ago1 watchersCompare

[ Source](https://github.com/getpop/hooks)[ Packagist](https://packagist.org/packages/getpop/hooks)[ Docs](https://github.com/getpop/hooks)[ RSS](/packages/getpop-hooks/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (9)Dependencies (5)Versions (27)Used By (3)

PoP Hooks
=========

[](#pop-hooks)

Contracts to implement hooks for PoP. The concept of a “hook” is the same [as in WordPress](https://developer.wordpress.org/plugins/hooks/): an “action” allows executing extra functionality, and a “filter” allows to modify a value.

Install
-------

[](#install)

Via Composer

```
composer require getpop/hooks
```

Development
-----------

[](#development)

The source code is hosted on the [PoP monorepo](https://github.com/leoloso/PoP), under [`Engine/packages/hooks`](https://github.com/leoloso/PoP/tree/master/layers/Engine/packages/hooks).

Usage
-----

[](#usage)

Initialize the component:

```
\PoP\Root\App::stockAndInitializeComponentClasses([([
    \PoP\Hooks\Component::class,
]);
```

Use it:

```
use PoP\Hooks\Facades\HooksAPIFacade;

// Get an instance of the service
$hooksapi = HooksAPI::getInstance();

// Add a hook for an Action
$hooksapi->addAction($actionName, $functionName, $priority, $argNum);

// Add a hook for a Filter
$hooksapi->addFilter($filterName, $functionName, $priority, $argNum);

// Execute an Action
$hooksapi->doAction($actionName, $param1, $param2, ...);

// Execute a Filter
$filterValue = $hooksapi->applyFilters($filterName, $filterValue, $param1, $param2, ...);

// Remove an Action
$hooksapi->removeAction($actionName, $functionName, $priority, $argNum);

// Remove a Filter
$hooksapi->removeFilter($filterName, $functionName, $priority, $argNum);
```

Architecture Design and Implementation
--------------------------------------

[](#architecture-design-and-implementation)

### Hooks

[](#hooks)

PoP uses hooks (as pioneered by [WordPress](https://codex.wordpress.org/Plugin_API)) everywhere, through both functions `doAction` and `applyFilters` as defined through interface `HooksAPI`, allowing any piece of code to be overridable by any 3rd party, or be injected extra functionality. For WordPress, the implementation of the interface is trivial. Other systems can rely on packages to implement this functionality (eg: [this one](https://github.com/tormjens/eventy) or [this one](https://github.com/voku/php-hooks)).

PHP versions
------------

[](#php-versions)

Requirements:

- PHP 8.0+ for development
- PHP 7.1+ for production

### Supported PHP features

[](#supported-php-features)

Check the list of [Supported PHP features in `leoloso/PoP`](https://github.com/leoloso/PoP/blob/master/docs/supported-php-features.md)

### Preview downgrade to PHP 7.1

[](#preview-downgrade-to-php-71)

Via [Rector](https://github.com/rectorphp/rector) (dry-run mode):

```
composer preview-code-downgrade
```

Standards
---------

[](#standards)

[PSR-1](https://www.php-fig.org/psr/psr-1), [PSR-4](https://www.php-fig.org/psr/psr-4) and [PSR-12](https://www.php-fig.org/psr/psr-12).

To check the coding standards via [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer), run:

```
composer check-style
```

To automatically fix issues, run:

```
composer fix-style
```

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Testing
-------

[](#testing)

To execute [PHPUnit](https://phpunit.de/), run:

```
composer test
```

Static Analysis
---------------

[](#static-analysis)

To execute [PHPStan](https://github.com/phpstan/phpstan), run:

```
composer analyse
```

Report issues
-------------

[](#report-issues)

To report a bug or request a new feature please do it on the [PoP monorepo issue tracker](https://github.com/leoloso/PoP/issues).

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

[](#contributing)

We welcome contributions for this package on the [PoP monorepo](https://github.com/leoloso/PoP) (where the source code for this package is hosted).

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE\_OF\_CONDUCT](CODE_OF_CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Leonardo Losoviz](https://github.com/leoloso)
- [All Contributors](../../../../../../contributors)

License
-------

[](#license)

GNU General Public License v2 (or later). Please see [License File](LICENSE.md) for more information.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 99.5% 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 ~37 days

Recently: every ~21 days

Total

26

Last Release

1627d ago

PHP version history (4 changes)0.1.0-alphaPHP ~7.1

0.1.7PHP ~7.2

0.7.6PHP ^7.4|^8.0

0.8.1PHP ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1981996?v=4)[Leonardo Losoviz](/maintainers/leoloso)[@leoloso](https://github.com/leoloso)

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

---

Top Contributors

[![leoloso](https://avatars.githubusercontent.com/u/1981996?v=4)](https://github.com/leoloso "leoloso (206 commits)")[![szepeviktor](https://avatars.githubusercontent.com/u/952007?v=4)](https://github.com/szepeviktor "szepeviktor (1 commits)")

---

Tags

hookspopwordpresshookspop

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[tormjens/eventy

The WordPress filter/action system in Laravel

438912.9k16](/packages/tormjens-eventy)[larapack/hooks

A Laravel Hook system

2171.5M21](/packages/larapack-hooks)[larapack/voyager-hooks

Hooks integrated in Voyager

2031.5M28](/packages/larapack-voyager-hooks)[bainternet/php-hooks

A fork of the WordPress filters hook system rolled in to a class to be ported into any PHP-based system

27621.3k2](/packages/bainternet-php-hooks)[voku/php-hooks

A fork of the WordPress filters hook system rolled in to a class to be ported into any PHP-based system

7637.3k3](/packages/voku-php-hooks)[wcm/git-php-hooks

Write git hooks with PHP, organize them on a per-project base and automatically add them

6441.1k3](/packages/wcm-git-php-hooks)

PHPackages © 2026

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