PHPackages                             altherius/gandalf - 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. altherius/gandalf

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

altherius/gandalf
=================

A tiny decision maker for PHP

01PHP

Since Oct 15Pushed 5y ago1 watchersCompare

[ Source](https://github.com/Altherius/gandalf)[ Packagist](https://packagist.org/packages/altherius/gandalf)[ RSS](/packages/altherius-gandalf/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

### Gandalf

[](#gandalf)

Gandalf is a tiny decision maker for your PHP Projects.

#### Installation

[](#installation)

Require gandalf with composer :

```
composer require altherius/gandalf

```

#### Getting started

[](#getting-started)

Gandalf uses a system of voters, implement your own voters implementing `Gandalf\Voter`with your own business logic :

```
class PostVoter implements \Gandalf\Voter
{
    public function abstains(string $permission, object $object): bool
    {
        if (!$object instanceof Post) {
            return true;
        }

        return false;
    }

    public function vote(string $permission, object $object): bool
    {
        /* Implement your decision logic here */
        return true;
    }
}
```

Then in your code, you can use the decision manager :

```
$post = new Post();
$decisionManager = new \Gandalf\DecisionManager();
$decisionManager->decide('edit', $post);
```

#### Strategies

[](#strategies)

The decision manager can decide according to 3 different strategies :

- `STRATEGY_AFFIRMATIVE`: If at least one voter responds affirmatively, the decision manager will have a positive decision. This is the default behaviour.
- `STRATEGY_UNANIMOUS`: All voters that do not abstain have to respond affirmatively.
- `STRATEGY_CONSENSUS`: A majority of voters have to respond affirmatively.

You can pass a strategy when you instanciate the `DecisionManager`.

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity1

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 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/12be256ad2f30b6b46cfd7e6504c6bbd63e927294db0a6e677c4bc2c1521b543?d=identicon)[Altherius](/maintainers/Altherius)

---

Top Contributors

[![Altherius](https://avatars.githubusercontent.com/u/6648753?v=4)](https://github.com/Altherius "Altherius (2 commits)")

### Embed Badge

![Health badge](/badges/altherius-gandalf/health.svg)

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

###  Alternatives

[infection/include-interceptor

Stream Wrapper: Include Interceptor. Allows to replace included (autoloaded) file with another one.

3124.2M5](/packages/infection-include-interceptor)[jeroen/rewindable-generator

Provides a simple adapter to make generators rewindable

1655.4k1](/packages/jeroen-rewindable-generator)

PHPackages © 2026

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