Download the PHP package asseco-voice/laravel-plan-router without Composer

On this page you can find all versions of the php package asseco-voice/laravel-plan-router. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-plan-router

Laravel plan router

This package is an extension of inbox package. 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

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

Rule

Attribute to match regex against.

Example:

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.

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

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

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. This will return a matched Plan in case of a successful match, or null in case of no match.

Example:

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:

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

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

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:

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.


All versions of laravel-plan-router with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
laravel/framework Version ^10.0
asseco-voice/laravel-inbox Version ^3.0
asseco-voice/laravel-common Version ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package asseco-voice/laravel-plan-router contains the following files

Loading the files please wait ....