PHPackages                             asseco-voice/laravel-plan-router - 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. [Framework](/categories/framework)
4. /
5. asseco-voice/laravel-plan-router

ActiveLibrary[Framework](/categories/framework)

asseco-voice/laravel-plan-router
================================

Laravel support for plan routing.

v6.1.1(2y ago)04.1k↓100%[5 PRs](https://github.com/asseco-voice/laravel-plan-router/pulls)MITPHPPHP ^8.1

Since Apr 8Pushed 1y ago5 watchersCompare

[ Source](https://github.com/asseco-voice/laravel-plan-router)[ Packagist](https://packagist.org/packages/asseco-voice/laravel-plan-router)[ RSS](/packages/asseco-voice-laravel-plan-router/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (8)Versions (31)Used By (0)

[![](https://github.com/asseco-voice/art/raw/main/evil_logo.png)](https://see.asseco.com)

Laravel plan router
===================

[](#laravel-plan-router)

This package is an extension of [inbox package](https://github.com/asseco-voice/laravel-inbox). Its main purpose is to provide the ability to define multiple `Plans` with certain regex rules, and upon providing some input return the matched `Plan`.

I.e. you may have one `Plan` matching `*@gmail` addresses, other one matching `*@yahoo.com` addresses. Provided the input, package will return either first or second plan, depending on the actual address provided.

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

[](#installation)

Install the package through composer. It is automatically registered as a Laravel service provider, so no additional actions are required.

`composer require asseco-voice/laravel-plan-router`

Terminology
-----------

[](#terminology)

### Rule

[](#rule)

Attribute to match regex against.

**Example**:

- For email, this can be: *from, to, cc, bcc, subject*
- For SMS, this can be: *from, to, body*

### Plan

[](#plan)

A user-friendly name for set of regex matches which must be matched in order for the plan to be hit. `Plan` is a many-to-many relation with `Rule` for which you can define the actual regex in a pivot table.

I.e.

```
Plan 1 -> from     *@gmail.com
       -> subject  *VIP*

Plan 2 -> from     *@yahoo.com

```

`priority` if two plans are a hit at the same time, higher priority plan has greater precedence, and if hit, all other callbacks which might be a match won't be hit.

`match_either` - functions as an OR/AND gate. If set to `true`, having more than one match defined, only one has to be matched for a plan to be hit. If set to `false`, all matches need to be hit in order for that particular plan to be hit.

Setup
-----

[](#setup)

To set up the package:

1. Run migrations with `artisan migrate`
2. Run (or include in your `DatabaseSeeder`) `PlanRouterPackageSeeder` to seed dummy data. For production, only `RuleSeeder` will be run as it is the only one mandatory for package to function. It defines what can your **raw** payload match by.
3. For any custom requirements, provide your own `RuleSeeder` instead of one from the package.

Usage
-----

[](#usage)

Call `InboxService::match()` in a place in your code where you're planning to receive the messages. Function takes a single parameter which is a class implementing a `CanMatch` interface, so be sure to dedicate a class which will parse your **raw** input and which you can then forward to the method.

Details about `CanMatch` implementation can be seen in [original package documentation](https://github.com/asseco-voice/laravel-inbox). This will return a matched `Plan` in case of a successful match, or `null` in case of no match.

Example:

```
public function __invoke(ReceiveEmailRequest $request)
{
    // email() is some arbitrary method in form request
    // returning a CanMatch instance from given request data.
    $canMatchInstance = $request->email();

    $matchedPlan = InboxService::match($canMatchInstance);

    return response('success');
}
```

### Plan - model values

[](#plan---model-values)

You can provide a set of `attribute => value` values for each plan which would be responsible for changing the attributes of a saved model (check the `plan_model_values` table). The model must use a `HasPlanValues` trait.

For example, having a `Message` model with attributes `title` and `description`, and two `Plans`with following values:

```
ID  plan_id attribute       value

1   1       title           New title
2   2       description     Modify this

```

Meaning that `Plan` 1 will modify title, and `Plan` 2 will modify description.

Now, when a hit happens, you can apply these modifications.

```
$message = Message::create([
    'title'         => 'some title',
    'description'   => 'some description',
]);

// Let's say Plan 2 was hit
$matchedPlan = InboxService::match($canMatchInstance);

$message->applyPlanValues($matchedPlan);

dd(
    $message->title,      // Will dump "some title" as Plan 2 doesn't have title in plan_model_values.
    $message->description // Will dump "Modify this" because of Plan 2 hit.
);
```

You can also set the `attribute` in the DB to be a relation name. It is a prerequisite a relation with that name exists on a model. In that case, the relation will be updated instead of the actual model attribute.

I.e. if `Message` belongs to a `Folder`, and has a `folder(): BelongsTo` method, you can define a `Plan` model values as such:

```
ID  plan_id attribute       value

1   1       folder          1

```

Extending the package
=====================

[](#extending-the-package)

Publishing the configuration will enable you to change package models as well as controlling how migrations behave. If extending the model, make sure you're extending the original model in your implementation.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 70.8% 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 ~43 days

Recently: every ~132 days

Total

25

Last Release

817d ago

Major Versions

v1.0.0 → v2.0.02021-06-07

v2.2.0 → v3.0.02021-08-11

v3.0.2 → v4.0.02022-04-12

v4.1.2 → v5.0.02022-05-05

v5.4.0 → v6.0.02023-08-08

PHP version history (3 changes)v0.1.0PHP ^7.4 || ^8.0

v5.0.0PHP ^8.0

v6.0.0PHP ^8.1

### Community

Maintainers

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

---

Top Contributors

[![Norgul](https://avatars.githubusercontent.com/u/11718157?v=4)](https://github.com/Norgul "Norgul (51 commits)")[![josip-milotic](https://avatars.githubusercontent.com/u/42002911?v=4)](https://github.com/josip-milotic "josip-milotic (8 commits)")[![AkronimBlack](https://avatars.githubusercontent.com/u/39061674?v=4)](https://github.com/AkronimBlack "AkronimBlack (5 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (5 commits)")[![ngaspari](https://avatars.githubusercontent.com/u/33628128?v=4)](https://github.com/ngaspari "ngaspari (2 commits)")[![assefvisic](https://avatars.githubusercontent.com/u/60132037?v=4)](https://github.com/assefvisic "assefvisic (1 commits)")

---

Tags

laravellaravel-packagematch-regexphp

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/asseco-voice-laravel-plan-router/health.svg)

```
[![Health](https://phpackages.com/badges/asseco-voice-laravel-plan-router/health.svg)](https://phpackages.com/packages/asseco-voice-laravel-plan-router)
```

###  Alternatives

[codewithdennis/larament

Larament is a time-saving starter kit to quickly launch Laravel 13.x projects. It includes FilamentPHP 5.x pre-installed and configured, along with additional tools and features to streamline your development workflow.

3691.5k](/packages/codewithdennis-larament)[ecotone/laravel

Laravel integration for Ecotone

21307.6k3](/packages/ecotone-laravel)

PHPackages © 2026

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