apurba-labs / laravel-approval-engine
Batch-based approval workflow engine for Laravel
Package info
github.com/apurba-labs/laravel-approval-engine
pkg:composer/apurba-labs/laravel-approval-engine
Requires
- php: ^8.4
- apurba-labs/laravel-iam: ^0.5
- illuminate/support: ^10.0|^11.0|^12.0|^13.0
Requires (Dev)
- doctrine/dbal: ^4.4
- orchestra/testbench: *
- phpunit/phpunit: ^10.0
This package is auto-updated.
Last update: 2026-05-15 20:36:45 UTC
README
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
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
