PHPackages                             shahajahan/approval-flow - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. shahajahan/approval-flow

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

shahajahan/approval-flow
========================

A dynamic, framework-agnostic approval access control system for any PHP framework (Laravel, CodeIgniter, CakePHP, Symfony, or plain PHP). Define and manage multi-level approval roles, with forward/backward flow and permission checks.

1.0.0(8mo ago)05MITPHPPHP &gt;=5.6CI failing

Since Oct 13Pushed 8mo agoCompare

[ Source](https://github.com/shahajahancse/approval-flow)[ Packagist](https://packagist.org/packages/shahajahan/approval-flow)[ RSS](/packages/shahajahan-approval-flow/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (1)Versions (2)Used By (0)

Approval Flow
=============

[](#approval-flow)

[![Packagist Version](https://camo.githubusercontent.com/7244b05a322272dc677182872fb8124fcb2035d1fb7f2166b6a3b35a65dc0216/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73686168616a6168616e2f617070726f76616c2d666c6f772e737667)](https://packagist.org/packages/shahajahan/approval-flow)[![License](https://camo.githubusercontent.com/f8df3091bbe1149f398a5369b2c39e896766f9f6efba3477c63e9b4aa940ef14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e)](LICENSE)![PHP Version](https://camo.githubusercontent.com/9872feb7427492c44fc3a1719f05349f2b752a03a8459627fe8e0b688ef82e6f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253345253344352e362d626c7565)![Build Status](https://camo.githubusercontent.com/78e9554c0a7464e64378d41b958d9ac4057acade52930f87cd387a78fee2493c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f73686168616a6168616e2f617070726f76616c2d666c6f772f7068702e796d6c)

A **dynamic approval access control system** for any PHP framework (Laravel, CodeIgniter, CakePHP, Symfony, or plain PHP). Define and manage **multi-level approval roles**, with **forward/backward flow** and **permission checks** — all framework-agnostic.

---

🚀 Features
----------

[](#-features)

✅ Framework-agnostic core ✅ Works with Laravel, CodeIgniter, Symfony, CakePHP, or raw PHP ✅ Dynamic approval hierarchy (forward/backward flow) ✅ Dynamic approval (forward/backward flow) with multiple approval flow on same project ✅ Simple adapter pattern for DB access (PDO, Query Builder, or ORM) ✅ PSR-4 and PSR-12 compliant ✅ Extensible and testable

---

🧩 Installation
--------------

[](#-installation)

### Via Composer

[](#via-composer)

```
composer require shahajahan/approval-flow
```

If you’re developing locally, clone the repo and link:

```
git clone https://github.com/shahajahancse/approval-flow.git
cd approval-flow
composer install
```

---

🗃️ Database Schema
------------------

[](#️-database-schema)

The recommended database schema is defined in [`database/schema.sql`](database/schema.sql). You can use this file to set up your tables. A migration file for Laravel is also available at [`database/migrations/2025_10_13_000000_create_approval_tables.php`](database/migrations/2025_10_13_000000_create_approval_tables.php).

---

⚙️ Usage Examples
-----------------

[](#️-usage-examples)

### 🔹 Laravel

[](#-laravel)

```
use ApprovalFlow\Services\ApprovalFlow;
use ApprovalFlow\Adapters\LaravelAdapter;

$flow = new ApprovalFlow(new LaravelAdapter());

$nextRole = $flow->nextRole(2);
$prevRole = $flow->previousRole(2);
$canApprove = $flow->canApprove(auth()->id(), $documentId);
```

---

### 🔹 CodeIgniter (v3 or v4)

[](#-codeigniter-v3-or-v4)

```
$flow = new \ApprovalFlow\Services\ApprovalFlow(
    new \ApprovalFlow\Adapters\CodeIgniterAdapter($this)
);

$next = $flow->nextRole($currentRoleId);
$canApprove = $flow->canApprove($user_id, $doc_id);
```

---

### 🔹 Symfony

[](#-symfony)

```
use ApprovalFlow\Services\ApprovalFlow;
use ApprovalFlow\Adapters\SymfonyAdapter;
use Doctrine\ORM\EntityManagerInterface;

// Assuming you have injected the EntityManager
$adapter = new SymfonyAdapter($entityManager);
$flow = new ApprovalFlow($adapter);

$nextRole = $flow->nextRole(1);
```

---

### 🔹 CakePHP

[](#-cakephp)

```
use ApprovalFlow\Services\ApprovalFlow;
use ApprovalFlow\Adapters\CakePHPAdapter;
use Cake\ORM\TableRegistry;

// Get the default ORM table
$usersTable = TableRegistry::getTableLocator()->get('Users');
$adapter = new CakePHPAdapter($usersTable);
$flow = new ApprovalFlow($adapter);

$nextRole = $flow->nextRole(1);
```

---

### 🔹 Plain PHP (PDO)

[](#-plain-php-pdo)

```
use ApprovalFlow\Services\ApprovalFlow;
use ApprovalFlow\Adapters\PdoAdapter;

$pdo = new PDO("mysql:host=localhost;dbname=test", "root", "");
$adapter = new PdoAdapter($pdo);
$flow = new ApprovalFlow($adapter);

if ($flow->canApprove(1, 100)) {
    echo "User can approve document!";
}
```

---

🧠 Architecture
--------------

[](#-architecture)

- **Core Logic:** `ApprovalFlow` (framework-independent)
- **Adapters:**
    - `LaravelAdapter` — Uses Laravel’s Query Builder (DB Facade)
    - `CodeIgniterAdapter` — Uses CI’s `$this->db` query builder
    - `PdoAdapter` — Uses native PDO
- **Contract:** `ApproverInterface` ensures consistency across adapters

---

🧰 Helper Functions
------------------

[](#-helper-functions)

```
approval_log("Approval started...");
// Output: [ApprovalFlow] 2025-10-13 11:00:00 - Approval started...
```

---

🧪 Running Tests
---------------

[](#-running-tests)

```
./vendor/bin/phpunit --bootstrap vendor/autoload.php tests
```

Sample test (`tests/ApprovalFlowTest.php`) is already included.

---

🧱 Folder Structure
------------------

[](#-folder-structure)

```
approval-flow/
│
├── src/
│   ├── Contracts/ApproverInterface.php
│   ├── Services/ApprovalFlow.php
│   ├── Adapters/
│   │   ├── LaravelAdapter.php
│   │   ├── CodeIgniterAdapter.php
│   │   └── PdoAdapter.php
│   └── Helpers/helper.php
│
├── tests/
│   └── ApprovalFlowTest.php
└── composer.json

```

---

🪪 License
---------

[](#-license)

This package is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

---

👨‍💻 Author
----------

[](#‍-author)

**Md Shahajahan Ali**📧 🌐 [GitHub: @shahajahan](https://github.com/shahajahancse)

---

🌟 Contributing
--------------

[](#-contributing)

Pull requests are welcome! To contribute:

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/your-feature`)
3. Commit changes and push
4. Submit a Pull Request 🎯

---

💡 Future Enhancements
---------------------

[](#-future-enhancements)

- Approval workflow templates (Leave, Expense, Purchase)
- Event hooks (`onApprove`, `onReject`)
- JSON-based flow configuration
- Role-based escalation and notifications

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance59

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity30

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

264d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/39066491?v=4)[Md. Shahajahan Ali](/maintainers/shahajahancse)[@shahajahancse](https://github.com/shahajahancse)

---

Top Contributors

[![shahajahancse](https://avatars.githubusercontent.com/u/39066491?v=4)](https://github.com/shahajahancse "shahajahancse (8 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/shahajahan-approval-flow/health.svg)

```
[![Health](https://phpackages.com/badges/shahajahan-approval-flow/health.svg)](https://phpackages.com/packages/shahajahan-approval-flow)
```

###  Alternatives

[kartik-v/yii2-password

Useful password strength validation utilities for Yii Framework 2.0

761.3M17](/packages/kartik-v-yii2-password)[vitalybaev/laravel5-dkim

Laravel 5/6 package for signing outgoing messages with DKIM.

3163.1k](/packages/vitalybaev-laravel5-dkim)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
