PHPackages                             speedyspec/speedyspec-wp-hook-infra-memory - 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. speedyspec/speedyspec-wp-hook-infra-memory

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

speedyspec/speedyspec-wp-hook-infra-memory
==========================================

SpeedySpec Rewrite of WordPress - Hook API Infrastructure Memory Package

0.0.4(5mo ago)00BSD-3-ClausePHPPHP &gt;=8.4CI passing

Since Jan 17Pushed 5mo agoCompare

[ Source](https://github.com/SpeedySpec/speedyspec-wp-hook-infra-memory)[ Packagist](https://packagist.org/packages/speedyspec/speedyspec-wp-hook-infra-memory)[ RSS](/packages/speedyspec-speedyspec-wp-hook-infra-memory/feed)WikiDiscussions main Synced today

READMEChangelog (3)Dependencies (2)Versions (3)Used By (0)

SpeedySpec WP Hook Infrastructure - Memory
==========================================

[](#speedyspec-wp-hook-infrastructure---memory)

An in-memory implementation of the WordPress hook system for the SpeedySpec WP Hook Domain package. This package provides lightweight, fast hook storage suitable for testing, CLI applications, and scenarios where persistent hook storage is not required.

**Note:** Version 1.x is not semver-compatible and should not be considered stable. Consider the 1.0 version 0.x for usage purposes. Version 2.x will be semver-compatible.

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

[](#installation)

```
composer require speedyspec/speedyspec-wp-hook-infra-memory
```

Requirements
------------

[](#requirements)

- PHP 8.4 or higher
- `speedyspec/speedyspec-wp-hook-domain` ^1.0

Quick Start
-----------

[](#quick-start)

### Basic Setup

[](#basic-setup)

```
use SpeedySpec\WP\Hook\Domain\HookServiceContainer;
use SpeedySpec\WP\Hook\Domain\Contracts\HookContainerInterface;
use SpeedySpec\WP\Hook\Domain\Contracts\CurrentHookInterface;
use SpeedySpec\WP\Hook\Domain\Contracts\HookRunAmountInterface;
use SpeedySpec\WP\Hook\Domain\Services\CurrentHookService;
use SpeedySpec\WP\Hook\Domain\Services\HookRunAmountService;
use SpeedySpec\WP\Hook\Infra\Memory\Services\MemoryHookContainer;

// Get the service container
$container = HookServiceContainer::getInstance();

// Register the memory infrastructure services (using interfaces for flexibility)
$container->add(HookRunAmountInterface::class, fn() => new HookRunAmountService());
$container->add(CurrentHookInterface::class, fn() => new CurrentHookService());
$container->add(
    HookContainerInterface::class,
    fn($c) => new MemoryHookContainer(
        $c->get(HookRunAmountInterface::class),
        $c->get(CurrentHookInterface::class)
    )
);

// Now use the hook system
$hooks = $container->get(HookContainerInterface::class);
```

### Using the ServiceProvider

[](#using-the-serviceprovider)

For convenience, you can use the included service provider:

```
use SpeedySpec\WP\Hook\Infra\Memory\ServiceProvider;
use SpeedySpec\WP\Hook\Domain\HookServiceContainer;
use SpeedySpec\WP\Hook\Domain\Contracts\CalledDeprecatedHookInterface;
use SpeedySpec\WP\Hook\Infra\Memory\Services\CalledDeprecatedHook;

$provider = new ServiceProvider();
$provider->register();

// If you need deprecated hook support, register CalledDeprecatedHook
$container = HookServiceContainer::getInstance();
$container->add(
    CalledDeprecatedHookInterface::class,
    fn() => new CalledDeprecatedHook()
);

// Services are now registered and ready to use
```

### Adding and Executing Hooks

[](#adding-and-executing-hooks)

```
use SpeedySpec\WP\Hook\Domain\Entities\ObjectHookInvoke;
use SpeedySpec\WP\Hook\Domain\ValueObject\StringHookName;

// Get the hook container
$hooks = HookServiceContainer::getInstance()->get(HookContainerInterface::class);

// Add a filter callback
$callback = new ObjectHookInvoke(
    fn(string $value) => strtoupper($value),
    priority: 10
);
$hooks->add(new StringHookName('my_filter'), $callback);

// Apply the filter
$result = $hooks->filter(new StringHookName('my_filter'), 'hello');
// Result: 'HELLO'

// Add an action callback
$actionCallback = new ObjectHookInvoke(
    fn(string $message) => error_log($message),
    priority: 10
);
$hooks->add(new StringHookName('my_action'), $actionCallback);

// Dispatch the action
$hooks->dispatch(new StringHookName('my_action'), 'Something happened');
```

When to Use This Package
------------------------

[](#when-to-use-this-package)

**Use this package when:**

- Writing unit or integration tests
- Building CLI applications
- Creating lightweight scripts
- Prototyping hook-based features
- Running in environments where hook state doesn't need persistence

**Consider alternatives when:**

- You need hooks to persist across requests
- You're building a full WordPress-compatible application
- You need the `WP_Hook` class compatibility

Documentation
-------------

[](#documentation)

For comprehensive documentation, see the [docs](./docs/) directory:

- [Services](./docs/services.md) - Detailed documentation of `MemoryHookContainer` and `MemoryHookSubject`
- [Testing](./docs/testing.md) - How to use this package in your tests
- [Examples](./docs/examples.md) - Common usage patterns and recipes

Testing
-------

[](#testing)

```
composer install
./vendor/bin/pest
```

License
-------

[](#license)

BSD-3-Clause

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance71

Regular maintenance activity

Popularity0

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 83.3% 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 ~6 days

Total

2

Last Release

162d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/314942?v=4)[Jacob Santos](/maintainers/jacobsantos)[@jacobsantos](https://github.com/jacobsantos)

---

Top Contributors

[![jacobsantos](https://avatars.githubusercontent.com/u/314942?v=4)](https://github.com/jacobsantos "jacobsantos (15 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (3 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/speedyspec-speedyspec-wp-hook-infra-memory/health.svg)

```
[![Health](https://phpackages.com/badges/speedyspec-speedyspec-wp-hook-infra-memory/health.svg)](https://phpackages.com/packages/speedyspec-speedyspec-wp-hook-infra-memory)
```

###  Alternatives

[braincrafted/background-process

Start processes in the background that continue running when the PHP process exists.

3006.1k1](/packages/braincrafted-background-process)[robole/sulu-ai-translator-bundle

Translate any type of content using DeepL

191.9k](/packages/robole-sulu-ai-translator-bundle)[stathisg/greek-slug-generator

A slug (pretty URL) generator, which supports Greek UTF-8 encoded characters

131.7k](/packages/stathisg-greek-slug-generator)

PHPackages © 2026

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