PHPackages                             samsin33/laravel-decision-engine - 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. samsin33/laravel-decision-engine

ActiveLibrary

samsin33/laravel-decision-engine
================================

This package provide support for making decision engine in laravel.

v1.0.0(3y ago)4112MITPHPPHP ^8.0

Since Nov 20Pushed 3y ago1 watchersCompare

[ Source](https://github.com/samsin33/laravel-decision-engine)[ Packagist](https://packagist.org/packages/samsin33/laravel-decision-engine)[ RSS](/packages/samsin33-laravel-decision-engine/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (16)Versions (2)Used By (0)

Introduction
------------

[](#introduction)

Decision Engine package for laravel. This package provide support for making decision engine in laravel version 9.

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

[](#installation)

Just install samsin33/laravel-decision-engine package with composer.

```
$ composer require samsin33/laravel-decision-engine
```

Database Migration
------------------

[](#database-migration)

Decision Engine service provider registers its own database migration directory, so remember to migrate your database after installing the package. The migrations will add 3 tables to your database:

```
$ php artisan migrate
```

If you need to overwrite the migrations that ship with this package, you can publish them using the vendor:publish Artisan command:

```
$ php artisan vendor:publish --tag="decision-engine-migrations"
```

If you would like to prevent Decision Engine's migrations from running entirely, you may use the ignoreMigrations method provided by DecisionEngine. Typically, this method should be called in the register method of your AppServiceProvider:

```
use Samsin33\DecisionEngine\DecisionEngine;

/**
 * Register any application services.
 *
 * @return void
 */
public function register()
{
    DecisionEngine::ignoreMigrations();
}
```

Publish Config
--------------

[](#publish-config)

If you need to overwrite the config file that ship with this package, you can publish them using the vendor:publish Artisan command:

```
$ php artisan vendor:publish --tag="decision-engine-config"
```

Env Configuration
-----------------

[](#env-configuration)

You can change your database connection for models, default will be your DB\_CONNECTION if not then mysql. If you wish to change this you can specify a different connection in your .env file:

```
DECISION_ENGINE_CONNECTION=mysql
```

You can change your database primary key type for models, default is bigInt. If you wish to change this to uuid you can specify it in your .env file.

For now only ***bit integer*** and ***uuid*** is supported.

```
DECISION_ENGINE_PRIMARY_KEY_TYPE=uuid
```

Publish Views
-------------

[](#publish-views)

You need to overwrite the view files that ship with this package and can change according to your design, you can publish them using the vendor:publish Artisan command:

```
$ php artisan vendor:publish --tag="decision-engine-views"
```

Showing and Creating Rule Engine
--------------------------------

[](#showing-and-creating-rule-engine)

For index page and create page of Rule Engine goto routes

```
/decision-engine/rule-engines
/decision-engine/rule-engines/create
```

You can add these routes to your menu to access them. All the required routes are already registered.

Rule Engine Types
-----------------

[](#rule-engine-types)

For now this package supports only 2 types of Rule Engine.

1. Code - Set of code will be executed which u will put in business rules column on the basis of the input you provide.
2. Command - A command will be executed which u will put in business rules column on the basis of the input you provide.

Route Guards
------------

[](#route-guards)

Your web routes are contained inside web\_guards. Your api routes are contained inside api\_guards. You can change them in config files.

Example - Making a calculator
-----------------------------

[](#example---making-a-calculator)

As an example lets a make a calculator.

Create a rule engine:

**Name** - Calculator

**Type** - Code

**Validation** - This should be an array of validation rules of your input. E.g. [![img.png](img.png)](img.png)You can also make your own validations and use.

**Business Rules** - This should be the code which runs when the validation will pass. [![img_1.png](img_1.png)](img_1.png)

**Status** - It should be active for rule execution.

Your business rules should always return a value to show an output.

For a command example. Make a command Calculator with:

**signature** - calc {num1} {num2} {process}

and in the Business Rules field should be:

**Business Rules** - calc $num1 $num2 $process

the output of command type has 2 attributes result and info

**result** - returns integer from command.

**info** - save the output of the command, i.e. anything printed in line, info, comment, question, warn, and error methods.

Executing Business Rules on input
---------------------------------

[](#executing-business-rules-on-input)

To execute business rules you need to call the api.

```
URL: /decision-engine/rule-executions

Headers: {
  "accept": "application/json",
  "content-type": "application/json"
}
# Other headers attributes depends on your api guards.

Request:
{
    "rule_execution": {
        "rule_engine_id": 1,
        "input": {
            "num1": 45,
            "num2": 6,
            "process": "add"
        }
    }
}

Response:
{
    "output": {
        "status": "Code Success",
        "output": {
            "add": 51
        }
    },
    "rule_execution": {
        "rule_engine_id": 1,
        "input": {
            "num1": 45,
            "num2": 6,
            "process": "add"
        },
        "id": 1,
        "status": "Code Success",
        "updated_at": "2022-11-20T16:10:59.000000Z",
        "created_at": "2022-11-20T16:10:58.000000Z",
        "output": "{\"add\":51}"
    }
}
```

**Note**

1. Input should be associative array.
2. Your input keys will be converted to variables in the business rules value.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity51

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

1270d ago

### Community

Maintainers

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

---

Top Contributors

[![samarthas](https://avatars.githubusercontent.com/u/26267886?v=4)](https://github.com/samarthas "samarthas (22 commits)")

---

Tags

laravelrule-enginedecision engine

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/samsin33-laravel-decision-engine/health.svg)

```
[![Health](https://phpackages.com/badges/samsin33-laravel-decision-engine/health.svg)](https://phpackages.com/packages/samsin33-laravel-decision-engine)
```

###  Alternatives

[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.5k25.9M107](/packages/laravel-cashier)[laravel/passport

Laravel Passport provides OAuth2 server support to Laravel.

3.4k85.0M532](/packages/laravel-passport)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k12.1M99](/packages/laravel-pulse)[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k43.5M5.2k](/packages/larastan-larastan)[psalm/plugin-laravel

Psalm plugin for Laravel

3274.9M308](/packages/psalm-plugin-laravel)

PHPackages © 2026

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