PHPackages                             parscore/laravel-parscore - 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. parscore/laravel-parscore

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

parscore/laravel-parscore
=========================

A lightweight and extensible rules engine for Laravel

00PHP

Since May 11Pushed 1y agoCompare

[ Source](https://github.com/ParsCore/laravel-parscore)[ Packagist](https://packagist.org/packages/parscore/laravel-parscore)[ RSS](/packages/parscore-laravel-parscore/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

ParsCore for Laravel
====================

[](#parscore-for-laravel)

A lightweight and extensible rules engine for Laravel. Parse and evaluate conditions with a simple syntax: `fn[param1,param2,...]`. Built with pure PHP for maximum compatibility and zero external dependencies.

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

[](#installation)

Install via Composer:

```
composer require parscore/laravel-parscore
```

The service provider is automatically registered via Laravel's auto-discovery.

Usage
=====

[](#usage)

```
use ParsCore\Laravel\ParsCore;

$parser = app(ParsCore::class);
$result = $parser->parse('AND[equals[1,1],greater_than[10,5]]');

if ($result) {
    echo "Condition met!";
}
```

Example Syntax
==============

[](#example-syntax)

- ### Check if values are equal and one is greater than another:

    [](#check-if-values-are-equal-and-one-is-greater-than-another)

    ```
    AND[equals[1,1],greater_than[10,5]]

    ```
- ### Nested conditions:

    [](#nested-conditions)

    ```
    OR[AND[equals[1,1],greater_than[10,5]],NOT[less_than[2,3]]]

    ```

Supported Commands
==================

[](#supported-commands)

- ### Logical Operators:

    [](#logical-operators)

    - ##### AND\[condition1,condition2,...\]: All conditions must be true.

        [](#andcondition1condition2-all-conditions-must-be-true)
    - ##### OR\[condition1,condition2,...\]: At least one condition must be true.

        [](#orcondition1condition2-at-least-one-condition-must-be-true)
    - ##### NOT\[condition\]: Negates the condition.

        [](#notcondition-negates-the-condition)
- ### Conditions:

    [](#conditions)

    - ##### equals\[value1,value2\]: Check if two values are strictly equal.

        [](#equalsvalue1value2-check-if-two-values-are-strictly-equal)
    - ##### greater\_than\[value1,value2\]: Check if value1 is greater than value2.

        [](#greater_thanvalue1value2-check-if-value1-is-greater-than-value2)
    - ##### less\_than\[value1,value2\]: Check if value1 is less than value2.

        [](#less_thanvalue1value2-check-if-value1-is-less-than-value2)

Extending ParsCore
==================

[](#extending-parscore)

- ### Define custom commands in app/ParsCore/CustomCommands.php to extend functionality without affecting package updates:

    [](#define-custom-commands-in-appparscorecustomcommandsphp-to-extend-functionality-without-affecting-package-updates)

    ```
