PHPackages                             whilesmart/eloquent-idp - 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. whilesmart/eloquent-idp

ActiveLibrary

whilesmart/eloquent-idp
=======================

Intelligent document processing for Laravel: turn an uploaded document into structured fields via a swappable, host-agnostic processor chain.

00PHP

Since Jul 12Pushed 1mo agoCompare

[ Source](https://github.com/whilesmartphp/eloquent-idp)[ Packagist](https://packagist.org/packages/whilesmart/eloquent-idp)[ RSS](/packages/whilesmart-eloquent-idp/feed)WikiDiscussions dev Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

whilesmart/eloquent-idp
=======================

[](#whilesmarteloquent-idp)

Intelligent document processing for Laravel: turn an uploaded document (invoice, receipt, statement) into structured fields through a swappable processor chain. Each document is scoped to an owner (a workspace, organization, user) through [`whilesmart/eloquent-owner-access`](https://github.com/whilesmartphp/eloquent-owner-access).

The package is host-agnostic. It does not hard-require an OCR service or an LLM: extraction and enrichment both sit behind contracts with null defaults, so it installs and tests without any external service.

Install
-------

[](#install)

```
composer require whilesmart/eloquent-idp
php artisan migrate

```

Routes register automatically under the `api` prefix with `auth:sanctum`. Set `IDP_REGISTER_ROUTES=false` to mount them yourself.

Owning model
------------

[](#owning-model)

Add the trait to whatever owns documents:

```
use Whilesmart\Idp\Traits\HasDocuments;

class Workspace extends Model
{
    use HasDocuments;
}

$workspace->documents; // MorphMany
```

Endpoints
---------

[](#endpoints)

MethodPathPurposeGET`/api/documents`List (filter by `owner_type`+`owner_id`, `kind`, `status`)POST`/api/documents/process`Create a document from an uploaded `file` or a `source_path`, then process itGET`/api/documents/{document}`ShowDELETE`/api/documents/{document}`Soft delete`process` accepts an owner (`owner_type`, `owner_id`), one of `file` or `source_path`, an optional `kind`, `mime`, and a `schema` array hinting the fields to extract.

How processing works
--------------------

[](#how-processing-works)

`DocumentService::process($document, $contents, $filename, $schema)`:

1. Picks the highest-priority `DocumentProcessor` whose `supports($mime, $ext)` returns true, or a null baseline when none does.
2. Runs it to get a structured baseline, plus the raw extraction text when the processor implements `ProvidesExtractionContext`.
3. Passes both through the bound `ExtractionEnricher` to produce the final `extracted` fields.
4. Stores `extracted`, `raw_text`, `status`, and fires `DocumentProcessed` (or `DocumentFailed`).

### Extraction engine

[](#extraction-engine)

`KreuzbergProcessor` extracts text and tables via the Kreuzberg service (POST `{base_url}/extract`). It stays inert until `idp.kreuzberg.base_url` is set, so nothing hits the network in tests. Point it at a running instance:

```
KREUZBERG_BASE_URL=http://kreuzberg:8000
KREUZBERG_AUTH_TYPE=bearer
KREUZBERG_AUTH_CREDENTIALS=your-token-here

```

Register your own processor by resolving the manager and calling `register($processor, $priority)`; a higher priority overrides the built-in engine for a type.

### Enrichment

[](#enrichment)

The default `NullEnricher` returns the baseline unchanged. To complete or validate fields with an LLM, bind your own implementation (the package does not require a specific LLM library):

```
use Whilesmart\Idp\Contracts\ExtractionEnricher;

$this->app->bind(ExtractionEnricher::class, PrismExtractionEnricher::class);
```

Events
------

[](#events)

`DocumentProcessed` and `DocumentFailed` carry the `Document` so the host can bridge results into its own systems.

Status
------

[](#status)

`DocumentStatus`: `pending`, `processing`, `completed`, `failed`. `kind` is a plain string, so new document kinds need no schema change.

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance59

Moderate activity, may be stable

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/a1ca6f6e01ecbfe6640ff410c4f0321054fb48d05a5f843c2b89887b90369bcd?d=identicon)[whilesmart](/maintainers/whilesmart)

---

Top Contributors

[![nfebe](https://avatars.githubusercontent.com/u/14317775?v=4)](https://github.com/nfebe "nfebe (1 commits)")

### Embed Badge

![Health badge](/badges/whilesmart-eloquent-idp/health.svg)

```
[![Health](https://phpackages.com/badges/whilesmart-eloquent-idp/health.svg)](https://phpackages.com/packages/whilesmart-eloquent-idp)
```

PHPackages © 2026

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