PHPackages                             switon/invocation - 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. switon/invocation

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

switon/invocation
=================

Method-level guard and interceptor contracts for managed invocations for Switon Framework

v1.0.0(1mo ago)0335MITPHPPHP &gt;=8.3CI passing

Since Jun 6Pushed 2mo agoCompare

[ Source](https://github.com/switon-php/invocation)[ Packagist](https://packagist.org/packages/switon/invocation)[ Docs](https://github.com/switon-php/invocation)[ RSS](/packages/switon-invocation/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (3)Versions (2)Used By (5)

Switon Invocation Package
=========================

[](#switon-invocation-package)

[![CI](https://camo.githubusercontent.com/5a8514f6ac6c5e452eed00c2094a57f76a61bc1cb700d035655cc57200d1d2f8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f737769746f6e2d7068702f696e766f636174696f6e2f63692e796d6c3f6272616e63683d6d61696e266c6162656c3d4349)](https://github.com/switon-php/invocation/actions/workflows/ci.yml) [![PHP 8.3+](https://camo.githubusercontent.com/c03f51341eebaefabbf137e291b20523fc74b4ffd084406d88524d266d95085d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e332532422d373737424234)](https://www.php.net/)

Switon's invocation hook contracts for method-level guards and interceptors.

This package defines the attributes and hook contracts; [Invoker](../invoker/README.md) executes them at runtime.

Highlights
----------

[](#highlights)

- **Attribute-based hooks:** guards and interceptors attach behavior directly to methods.
- **Pre-execution checks:** guarded methods can be examined before they run.
- **Around-call wrapping:** interceptors can run before, after, or on exception.
- **Reusable base hook:** `Interceptor` covers the common partial-lifecycle case.
- **Reusable invocation path:** other components can share the same call flow.

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

[](#installation)

```
composer require switon/invocation
```

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

[](#quick-start)

```
use Attribute;
use ReflectionMethod;
use Switon\Invocation\Attribute\GuardInterface;
use Switon\Http\Exception\ForbiddenException;
use Switon\Http\RequestInterface;

#[Attribute(Attribute::TARGET_METHOD)]
final class IpGuard implements GuardInterface
{
    public function __construct(
        private array $ips,
    ) {
    }

    public function handle(RequestInterface $request, ReflectionMethod $method): void
    {
        if (!in_array($request->ip(), $this->ips, true)) {
            throw ForbiddenException::of('Access denied.');
        }
    }
}

final class AccountService
{
    #[IpGuard(['127.0.0.1'])]
    public function deleteAction(int $id): void
    {
    }
}
```

Docs:

License
-------

[](#license)

MIT.

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance87

Actively maintained with recent releases

Popularity11

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity48

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

48d ago

### Community

Maintainers

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

---

Top Contributors

[![switon-php](https://avatars.githubusercontent.com/u/247358032?v=4)](https://github.com/switon-php "switon-php (5 commits)")

---

Tags

attributesguardinterceptorinvocationswitonattributeinterceptorinvocationswiton

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/switon-invocation/health.svg)

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

###  Alternatives

[koriym/attributes

An annotation/attribute reader

443.6M14](/packages/koriym-attributes)[iteks/laravel-enum

A comprehensive Laravel package providing enhanced enum functionalities, including attribute handling, select array conversions, and fluent facade interactions for robust enum management in Laravel applications.

2519.5k](/packages/iteks-laravel-enum)[baibaratsky/yii2-serialized-attributes-behavior

Yii2 Serialized Attributes Behavior

1275.5k9](/packages/baibaratsky-yii2-serialized-attributes-behavior)[flagbit/table-attribute-bundle

The Flagbit Table Attribute Bundle for Akeneo PIM gives you the possibility to enrich your product with multi-dimensional data presentation in the form of tables, allowing you maximum flexibility within the PIM.

2310.5k](/packages/flagbit-table-attribute-bundle)[princejohnsantillan/reflect

Clearer API for PHP Attributes and Reflection.

1612.0k](/packages/princejohnsantillan-reflect)

PHPackages © 2026

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