PHPackages                             tareef/laravel - 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. [API Development](/categories/api)
4. /
5. tareef/laravel

ActiveLibrary[API Development](/categories/api)

tareef/laravel
==============

Official Laravel SDK for the Tareef face-recognition API — register, verify, and manage people in one line of code.

0.0.4(3w ago)7170↑271.4%MITPHPPHP ^8.2

Since Jun 5Pushed 3w agoCompare

[ Source](https://github.com/hussein4alaa/tareef-laravel)[ Packagist](https://packagist.org/packages/tareef/laravel)[ Docs](https://tareef.io)[ RSS](/packages/tareef-laravel/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (4)Dependencies (10)Versions (5)Used By (0)

 [ ![Tareef — Face recognition API](banner.png) ](https://tareef.io)

Tareef for Laravel
==================

[](#tareef-for-laravel)

The official Laravel SDK for [Tareef](https://tareef.io) — register a person, verify a face, manage your library, in one line of code.

```
use Tareef\Laravel\Facades\Tareef;

$result = Tareef::verify($request->file('selfie'));

if ($result->matched) {
    return "Welcome back, {$result->name}.";
}
```

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 10, 11, 12, or 13
- A Tareef account ([sign up free](https://tareef.io/register))

Install
-------

[](#install)

```
composer require tareef/laravel
```

The package self-registers via Laravel's auto-discovery. Add your API key to `.env`:

```
TAREEF_API_KEY=frs_live_xxxxxxxxxxxxxxxxxxxxxxxx
```

Grab your key from the Tareef dashboard → **API Keys** → **Create new key**.

Optionally publish the config to tune timeouts / retries:

```
php artisan vendor:publish --tag=tareef-config
```

Quickstart
----------

[](#quickstart)

### Enroll a person

[](#enroll-a-person)

```
use Tareef\Laravel\Facades\Tareef;

$person = Tareef::register(
    name:   $request->input('name'),
    images: [$request->file('photo')],   // UploadedFile, file path, or SplFileInfo
    phone:  $request->input('phone'),    // optional
);

return response()->json([
    'uuid' => $person->uuid,
    'images_indexed' => $person->imageCount,
]);
```

### Verify a face

[](#verify-a-face)

```
$result = Tareef::verify($request->file('selfie'));

if ($result->matched) {
    return view('door.open', [
        'name'  => $result->name,
        'score' => $result->score,    // lower = closer match
    ]);
}

return view('door.unknown');
```

### Compare two faces (1:1)

[](#compare-two-faces-11)

Measure how similar two images are without enrolling anyone — ideal for KYC ("does this selfie match this ID photo?"). A no-match is **not** an exception.

```
$result = Tareef::compare($request->file('selfie'), $request->file('id_photo'));

if ($result->match) {
    return 'Same person — '.round($result->similarity * 100).'% similar';
}
// $result->distance (lower = closer), $result->similarity (1.0 = identical)
```

### Add more reference photos

[](#add-more-reference-photos)

```
$person = Tareef::find($uuid);
$person->addImages([
    $request->file('photo_1'),
    $request->file('photo_2'),
]);
```

### List your library

[](#list-your-library)

```
$people = Tareef::list(limit: 50);
// Illuminate\Support\Collection

foreach ($people as $p) {
    echo "{$p->name} — {$p->imageCount} photos\n";
}
```

### Delete a person

[](#delete-a-person)

```
Tareef::delete($uuid);
// or, if you already have the object:
$person->delete();
```

### Health check

[](#health-check)

```
if (! Tareef::health()) {
    Log::warning('Tareef is unreachable.');
}
```

Error handling
--------------

[](#error-handling)

Every failure path throws a typed exception subclassed from `Tareef\Laravel\Exceptions\TareefException`.

```
use Tareef\Laravel\Exceptions\{
    FaceAlreadyExistsException,
    NoFaceDetectedException,
    QuotaExceededException,
    AuthenticationException,
    ServiceUnavailableException,
    TareefException,
};

try {
    $person = Tareef::register(name: $name, images: [$file]);
} catch (FaceAlreadyExistsException $e) {
    // Same face is already enrolled — fetch the existing record.
    $existing = Tareef::find($e->existingUuid);
    return back()->with('warning', "Already enrolled as {$existing->name}.");
} catch (NoFaceDetectedException $e) {
    return back()->withErrors(['photo' => 'No face was detected. Try a clearer photo.']);
} catch (QuotaExceededException) {
    return redirect()->route('billing')->with('error', 'Plan quota exhausted.');
} catch (AuthenticationException) {
    Log::critical('TAREEF_API_KEY is missing or revoked.');
    abort(500);
} catch (ServiceUnavailableException) {
    return back()->with('error', 'Tareef is having issues. Try again in a minute.');
} catch (TareefException $e) {
    report($e);
    return back()->with('error', $e->getMessage());
}
```

`Tareef::verify()` and `Tareef::compare()` are different: a no-match is **not** an exception — they return a result object with `matched`/`match` set to `false`. Only auth, quota, "no face in the image", and network errors throw.

API reference
-------------

[](#api-reference)

CallReturnsThrows on …`Tareef::register($name, $images, $phone?)``Person`duplicate face, no face, auth, quota`Tareef::verify($image)``VerifyResult`no face, auth, quota, network`Tareef::compare($imageA, $imageB)``CompareResult`no face, auth, quota, network`Tareef::find($uuid)``?Person` (null = not found)auth`Tareef::findOrFail($uuid)``Person`not found, auth`Tareef::list($limit = 100)``Collection`auth`Tareef::addImagesTo($uuid, $images)``Person` (refreshed)not found, auth, quota`Tareef::delete($uuid)``true`not found, auth`Tareef::health()``bool`never throws### `Person`

[](#person)

```
$person->uuid;          // string
$person->name;          // ?string
$person->phone;         // ?string
$person->imageCount;    // int
$person->images;        // string[]  — URLs/paths returned by the API
$person->createdAt;     // ?Carbon\Carbon

$person->addImages([$file]);   // → Person
$person->delete();             // → bool
$person->toArray();            // → array
```

### `VerifyResult`

[](#verifyresult)

```
$result->matched;       // bool   — branch on this
$result->uuid;          // ?string (the matched person's UUID, if any)
$result->name;          // ?string
$result->score;         // ?float  (lower = closer; samples;       // ?int    (how many reference photos contributed)
$result->status;        // 'ok' | 'not_found'
$result->message;       // ?string
```

### `CompareResult`

[](#compareresult)

```
$result->match;         // bool   — same person? (uses the app's strictness)
$result->distance;      // ?float  (cosine distance; lower = closer)
$result->similarity;    // ?float  (1 − distance; 1.0 = identical)
$result->threshold;     // ?float  (the cutoff the decision used)
$result->status;        // 'ok'
```

Configuration
-------------

[](#configuration)

`config/tareef.php` (publish to override):

KeyEnv varDefaultNotes`api_key``TAREEF_API_KEY`—**Required.** Bearer token, treat like a password.`base_url``TAREEF_BASE_URL``https://tareef.io`Override for self-hosted Tareef.`timeout``TAREEF_TIMEOUT``30`Per-request, seconds.`retries``TAREEF_RETRIES``2`Transient-failure retries before throwing.`throw_on_quota``TAREEF_THROW_ON_QUOTA``true`Set to `false` to receive failure results instead of `QuotaExceededException`.Image inputs
------------

[](#image-inputs)

Every method that takes images accepts any of:

- `\Illuminate\Http\UploadedFile` — straight from `$request->file('photo')`
- `\SplFileInfo` / `\Illuminate\Http\File` — for files you've already moved
- `string` — an absolute path on disk

The SDK streams them as multipart parts; nothing is loaded fully into PHP memory.

Testing your integration
------------------------

[](#testing-your-integration)

`Tareef` uses Laravel's HTTP client under the hood, so you can mock it with the standard `Http::fake()`:

```
use Illuminate\Support\Facades\Http;

Http::fake([
    '*/api/v1/verify' => Http::response([
        'success' => true, 'uuid' => 'fixture-uuid',
        'name' => 'Test Person', 'score' => 0.1, 'samples' => 1,
    ]),
]);

$result = Tareef::verify(UploadedFile::fake()->image('selfie.jpg'));

$this->assertTrue($result->matched);
$this->assertSame('Test Person', $result->name);
```

Versioning
----------

[](#versioning)

Semver. The first stable release is `1.0.0`. Any breaking change to the public API (`Tareef::*`, the resource DTOs, or the exception hierarchy) bumps the major version.

License
-------

[](#license)

MIT. See [LICENSE](LICENSE).

Links
-----

[](#links)

- Tareef dashboard —
- API reference —
- Status —
- Support —

tareef-laravel
==============

[](#tareef-laravel)

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance95

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity39

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

Every ~9 days

Total

4

Last Release

22d ago

### Community

Maintainers

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

---

Top Contributors

[![hussein4alaa](https://avatars.githubusercontent.com/u/13614747?v=4)](https://github.com/hussein4alaa "hussein4alaa (5 commits)")

---

Tags

apilaravelsdkverificationface-recognitionbiometricstareef

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tareef-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/tareef-laravel/health.svg)](https://phpackages.com/packages/tareef-laravel)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.3M347](/packages/psalm-plugin-laravel)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

813336.8k3](/packages/defstudio-telegraph)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

77922.3M186](/packages/laravel-mcp)[api-platform/laravel

API Platform support for Laravel

58174.6k17](/packages/api-platform-laravel)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5022.6k](/packages/simplestats-io-laravel-client)

PHPackages © 2026

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