Download the PHP package samsin33/laravel-decision-engine without Composer
On this page you can find all versions of the php package samsin33/laravel-decision-engine. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download samsin33/laravel-decision-engine
More information about samsin33/laravel-decision-engine
Files in samsin33/laravel-decision-engine
Package laravel-decision-engine
Short Description This package provide support for making decision engine in laravel.
License MIT
Informations about the package laravel-decision-engine
Introduction
Decision Engine package for laravel. This package provide support for making decision engine in laravel version 9.
Installation
Just install samsin33/laravel-decision-engine package with composer.
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:
If you need to overwrite the migrations that ship with this package, you can publish them using the vendor:publish Artisan command:
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:
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:
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:
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.
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:
Showing and Creating Rule Engine
For index page and create page of Rule Engine goto routes
You can add these routes to your menu to access them. All the required routes are already registered.
Rule Engine Types
For now this package supports only 2 types of Rule Engine.
- Code - Set of code will be executed which u will put in business rules column on the basis of the input you provide.
- Command - A command will be executed which u will put in business rules column on the basis of the input you provide.
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
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. You can also make your own validations and use.
Business Rules - This should be the code which runs when the validation will pass.
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
To execute business rules you need to call the api.
Note
- Input should be associative array.
- Your input keys will be converted to variables in the business rules value.
All versions of laravel-decision-engine with dependencies
ext-json Version *
guzzlehttp/guzzle Version ^7.2
illuminate/log Version ^9.0
illuminate/notifications Version ^9.0
illuminate/routing Version ^9.0
illuminate/view Version ^9.0
illuminate/console Version ^9.0
illuminate/container Version ^9.0
illuminate/contracts Version ^9.0
illuminate/cookie Version ^9.0
illuminate/database Version ^9.0
illuminate/encryption Version ^9.0
illuminate/http Version ^9.0
illuminate/support Version ^9.0