apurba-labs/laravel-approval-engine

Batch-based approval workflow engine for Laravel

Maintainers

Package info

github.com/apurba-labs/laravel-approval-engine

pkg:composer/apurba-labs/laravel-approval-engine

Statistics

Installs: 18

Dependents: 0

Suggesters: 0

Stars: 10

Open Issues: 0

v1.5.0 2026-05-15 20:36 UTC

This package is auto-updated.

Last update: 2026-05-15 20:36:45 UTC


README

Laravel PHP License GitHub stars

Stop Email Spam. Start Smart Approvals.

A modular, batch-based, multi-stage approval workflow engine for Laravel. Designed for real-world enterprise workflows -- it handles high-volume enterprise requests into actionable notification batches with email-based approvals and fully configurable stages..

Demo (Real Workflow)

πŸ‘‰ Create Request β†’ Batch β†’ Approval β†’ Timeline β†’ Done

🚧 Demo GIF coming soon (actively working on UI)

Meanwhile, you can test locally:

php artisan approval:demo

πŸ—οΈ Active Development (UI Layer)

We are currently building the frontend components to provide a full "Plug & Play" experience.

Component Status Description
🧾 Workflow List πŸ‘· In Progress A management dashboard for all active batches.
🧠 Approval Timeline 🎨 Designing A visual history of who approved/rejected and when.
πŸ” IAM Dashboard βš™οΈ Backend Ready Powered by laravel-iam for scoped RBAC management.

πŸ‘‰ Note: Screenshots and a full Demo GIF will be added in upcoming releases as the UI components are finalized.

Why This Package? Solving "Approval Fatigue"

In most enterprise systems:

  • Email Spam: 100 purchase requests = 100 separate emails to the Manager. πŸ˜“
  • Hardcoded Logic: Approval steps are buried inside Controllers or Models.
  • No Escalation: No built-in way to remind pending approvers or escalate.

Laravel Approval Engine solves this by separating the Workflow Logic from your Business Models and grouping requests into smart batches.

Key Features

  • πŸ“¦ Smart Batching: Group 50 records into 1 single email/notification.
  • ⛓️ Multi-Stage Workflows: Define paths like Requisition -> HOS -> COO -> Finance.
  • πŸ”— Secure Token-Based Approval: Approve or Reject directly from email or Slack via expiring secure links.
  • 🧩 Zero-Coupling: Works with any Eloquent model without altering your schema.
  • ⏳ Escalation Engine: (v2.0) Automatic reminders and "Escalate to Higher Role" logic.
  • πŸš€ IAM Ready: Integrates with Laravel IAM for scoped authority.

Engineering Philosophy

This package is built on a simple belief:

Workflow logic should not live inside controllers or models.

Modern systems require:

  • Separation of concerns
  • Scalable architecture
  • Configurable business logic

Instead of hardcoding approval flows, this engine provides:

  • βœ… Modular workflow design (plug & play modules)
  • βœ… Headless architecture (UI-agnostic, API-first)
  • βœ… Database-driven configuration (no redeploy needed)
  • βœ… IAM-based authorization (not role hardcoding)

This allows teams to evolve workflows without rewriting core logic.

Architectural Maturity

The PHP ecosystem is evolving beyond framework defaults toward clean, scalable architecture.

Recent industry trends emphasize:

  • Moving from fat controllers β†’ Action & DTO-based architecture
  • Designing configurable, database-driven systems
  • Building enterprise-grade workflow engines and scoring systems
  • Reducing dependency on external SaaS by building in-house solutions
  • Improving observability, auditability, and system transparency

At Apurba Labs, this is not a trend β€” it’s the foundation.

Our systems are designed to:

  • Be modular and extensible
  • Support complex business logic (workflows, approvals, IAM)
  • Operate in high-scale, event-driven environments
  • Remain framework-agnostic and future-proof

How This Project Aligns

Laravel Approval Engine is built following modern architectural principles:

  • βœ… Action-driven workflow execution (no fat controllers)
  • βœ… IAM-based authorization (permission-first, not role-only)
  • βœ… Modular workflow modules (plug & play architecture)
  • βœ… Database-driven workflow configuration
  • βœ… Full auditability of approval lifecycle
  • βœ… Batch-based processing for high-volume systems

This makes the engine suitable for enterprise-grade applications and SaaS platforms.

Example Use Cases

  • 🧾 Requisition Approval (HOS β†’ COO)
  • πŸ’° Invoice Approval (Manager β†’ Finance β†’ CFO)
  • πŸ›’ Purchase Workflow
  • πŸ§‘β€πŸ’Ό Leave Approval System

How It Works

graph TD
    A[Create Request] --> B[Batch Created]
    B --> C[Email Sent]
    C --> D[User Clicks Link]
    D --> E[Approve / Reject]
    E --> F[Next Stage]
    F --> G[Workflow Completed]
Loading

⏱ Escalation & Reminder Flow

graph TD
    A[Batch Sent] --> B[Wait]
    B --> C{Approved?}
    C -- No --> D[Reminder]
    D --> E{Still Pending?}
    E -- Yes --> F[Escalate]
Loading

Quick Start (2 Minutes)

git clone https://github.com/apurba-labs/laravel-approval-engine

cd laravel-approval-engine/example/laravel-demo

composer install
cp .env.example .env
php artisan key:generate

php artisan migrate
php artisan approval:demo

πŸ‘‰ Output:

βœ” Sample data created
βœ” Batch generated
βœ” Approval link generated

Demo Screenshot

Workflow

Installation

composer require apurba-labs/laravel-approval-engine

Setup

php artisan vendor:publish --tag=approval-config
php artisan migrate
php artisan db:seed --class="ApurbaLabs\ApprovalEngine\Database\Seeders\WorkflowDatabaseSeeder"

Create Workflow Module

php artisan make:workflow-module Requisition

Example: Define Module

class RequisitionModule extends BaseWorkflowModule
{
    public function model(): string
    {
        return \App\Models\Requisition::class;
    }

    /**
     * Validate records before they enter a batch.
     * Useful for checking data integrity or custom business rules.
     */
    public function validate(array $data): void
    {
        // Default: No validation required
        validator($data, [
            'total_amount' => 'required|numeric|min:1',
            'user_id' => 'required|exists:users,id',
        ])->validate();
    }

    public function approvedColumn(): string
    {
        return 'approved_at';
    }
    
    /**
     * Default status column name. 
     * Override this in the child class if it differs.
     */
    public function statusColumn(): string
    {
        return 'status';
    }

    /**
     * Default priorities: check for 'user', then 'creator'.
     * Individual modules can override this.
     */
    public function ownerRelations(): array
    {
        return ['user', 'creator'];
    }

    /**
     * Allow developers to add extra relations (like 'items' or 'department').
     */
    protected function customRelations(): array
    {
        return [];
    }


    public function selectColumns(): array
    {
         return [
            'id',
            'user_id',
            'reference_id',
            'stage',
            'stage_status',
            'status',
            'approved_at',
        ];
    }

    public function displayColumns(): array
    {
        return [
            'reference_id' => 'Reference',
            'user.name' => 'Requested By',
        ];
    }
    public function relationModels(): array
    {
        return [
            'user' => \ApurbaLabs\ApprovalEngine\Tests\Support\Models\User::class,
            //'admin' => \App\Models\Admin::class,
        ];
    }
}

πŸ” Token-Based Approval API

Approve workflows securely without login using expiring tokens.

POST /api/v1/approvals/token/approve

Example Request:

{
  "token": "secure-token-here"
}

Behavior
- Validates token (expiry + usage)
- Resolves workflow + approver
- Executes approval via engine
- Marks token as used

πŸ‘‰ Perfect for:

- Email approvals
- Slack / Teams integrations
- External systems

RBAC Integration (laravel-iam)

This engine works seamlessly with:
πŸ‘‰ Role-based access control (RBAC)
πŸ‘‰ Permission-based approval resolution

Example:

$user->can('approval.approve');

Architecture (Clean & Headless)

graph TD
    A[Adapters: API / CLI / Queue] --> B[Workflow Manager]
    B --> C[Workflow Engine]
    C --> D[Domain Models]
    C --> E[Rule Resolver]
    C --> F[Stage Navigator]
    C --> G[Events]

    G --> H[Listeners]
    H --> I[Notifications]
    I --> J[Batch Processor]

    B --> K[Token Service]
Loading

Commands

php artisan approval:send-batch
php artisan approval:status

Why This Engine is Different

Unlike traditional Laravel packages:

- ❌ No fat controllers
- ❌ No hardcoded approval flows
- ❌ No tight coupling with models

Instead:

- βœ… Headless workflow engine
- βœ… Event-driven lifecycle
- βœ… Token-based approvals
- βœ… Smart batching (enterprise-grade)
- βœ… IAM-ready (RBAC, multi-tenant future)

Roadmap

### v1.4 (Current 🚧)

βœ… Workflow engine \
βœ… IAM integration \
πŸ”œ Filament UI \
πŸ”œ Rule Builder (no-code)

### v2.0

πŸ”œ Slack / Teams integration \
πŸ”œ Advanced analytics

### v3.0 (SaaS)
πŸ”œ Multi-tenant system \
πŸ”œ API platform
πŸ”œ Dashboard (Next.js)

⭐ Support the Project

If this package has helped you streamline your enterprise workflows, please consider supporting it:

*   **Star the Repo** – It helps other developers find this tool.
*   **Share with your Team** – Spread the word to your fellow Laravel developers.
*   **Contribute** – Submit a PR or open an issue to help make it even better.

πŸ’Ό Consulting & Implementation

This engine is actively used as the foundation for scalable approval systems.

If you need help designing or integrating:

  • Workflow engines
  • Approval pipelines
  • Multi-tenant SaaS systems

Feel free to reach out.

πŸ“© Connect on LinkedIn
πŸ“§ apurbansinghdev@gmail.com

🀝 Contributing

PRs are welcome.

License

MIT License