PHPackages                             maat/waffarha - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. maat/waffarha

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

maat/waffarha
=============

integrate Waffarha with Maat

v1.0.3(2w ago)05↓100%MITPHPPHP ^8.2

Since May 22Pushed 2w agoCompare

[ Source](https://github.com/bendaryy/waffarha)[ Packagist](https://packagist.org/packages/maat/waffarha)[ RSS](/packages/maat-waffarha/feed)WikiDiscussions master Synced 1w ago

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

Waffarha Laravel Package
========================

[](#waffarha-laravel-package)

A Laravel package that provides a lightweight HTTP client and facade for integrating with the Maat API from any external application (e.g. Waffarha).

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

[](#requirements)

- PHP `^8.2`
- Laravel `10.x` / `11.x` / `12.x` / `13.x`

Installation
------------

[](#installation)

Install via Composer:

```
composer require maat/waffarha
```

The package will be auto-discovered. Both the service provider and the `Waffarha` facade are registered automatically via Laravel package discovery.

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

[](#configuration)

Publish the configuration file:

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

This creates `config/waffarha.php`. Add the following variables to your `.env`:

```
MAAT_URL=https://your-maat-host.example.com
MAAT_CLIENT_ID=your-client-id
MAAT_CLIENT_SECRET=your-client-secret
MAAT_API_TIMEOUT=30
```

### Configuration Options

[](#configuration-options)

KeyEnv VariableDefaultDescription`base_url``MAAT_URL``null`Base URL of the Maat API host.`client_id``MAAT_CLIENT_ID``null`OAuth client identifier issued by Maat.`client_secret``MAAT_CLIENT_SECRET``null`OAuth client secret issued by Maat.`timeout``MAAT_API_TIMEOUT``30`HTTP request timeout (seconds).Authentication
--------------

[](#authentication)

Maat exposes a Laravel Passport `client_credentials` endpoint for the Waffarha integration. Before calling any protected endpoint, obtain an access token from:

```
POST {MAAT_URL}/waffarha/oauth/token
Content-Type: application/json
Accept: application/json

{
    "grant_type": "client_credentials",
    "client_id": "{MAAT_CLIENT_ID}",
    "client_secret": "{MAAT_CLIENT_SECRET}",
    "scope": "*"
}
```

### Successful Response

[](#successful-response)

The Maat OAuth server uses a customised `client_credentials` grant that also issues a refresh token (default refresh TTL: **1 month**):

```
{
    "token_type": "Bearer",
    "expires_in": 31536000,
    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9...",
    "refresh_token": "def50200a8c4b2e7..."
}
```

### Using the Access Token

[](#using-the-access-token)

Send the returned `access_token` as a `Bearer` token on the `Authorization` header of every subsequent request:

```
GET {MAAT_URL}/waffarha/units
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9...
Accept: application/json
```

### Refreshing the Access Token

[](#refreshing-the-access-token)

When the access token expires, exchange the saved `refresh_token` for a new pair without re-sending the client secret elsewhere. Hit the same `/oauth/token` endpoint with `grant_type=refresh_token`:

```
POST {MAAT_URL}/waffarha/oauth/token
Content-Type: application/json
Accept: application/json

{
    "grant_type": "refresh_token",
    "refresh_token": "def50200a8c4b2e7...",
    "client_id": "{MAAT_CLIENT_ID}",
    "client_secret": "{MAAT_CLIENT_SECRET}",
    "scope": "*"
}
```

The response shape is identical to the initial token request — a new `access_token` **and** a fresh `refresh_token` (the old refresh token is invalidated).

### Examples with cURL

[](#examples-with-curl)

Obtain initial token:

```
curl -X POST "$MAAT_URL/waffarha/oauth/token" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "grant_type": "client_credentials",
    "client_id": "'"$MAAT_CLIENT_ID"'",
    "client_secret": "'"$MAAT_CLIENT_SECRET"'",
    "scope": "*"
  }'
```

Refresh an existing token:

```
curl -X POST "$MAAT_URL/waffarha/oauth/token" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "grant_type": "refresh_token",
    "refresh_token": "'"$MAAT_REFRESH_TOKEN"'",
    "client_id": "'"$MAAT_CLIENT_ID"'",
    "client_secret": "'"$MAAT_CLIENT_SECRET"'",
    "scope": "*"
  }'
```

Usage
-----

[](#usage)

### Using the Facade

[](#using-the-facade)

```
use Maat\Waffarha\Facades\Waffarha;

$units = Waffarha::getUnits(['page' => 1, 'per_page' => 20]);

$unit = Waffarha::getUnit('unit-uuid-here');
```

### Using Dependency Injection

[](#using-dependency-injection)

```
use Maat\Waffarha\WaffarhaClient;

class SyncUnitsJob
{
    public function __construct(protected WaffarhaClient $waffarha) {}

    public function handle(): void
    {
        $units = $this->waffarha->getUnits();

        // ...
    }
}
```

### Using the Service Container

[](#using-the-service-container)

```
$client = app('waffarha');
$units = $client->getUnits();
```

### Custom Requests

[](#custom-requests)

For endpoints not covered by helper methods, use the generic `request()` method:

```
use Maat\Waffarha\Facades\Waffarha;

$response = Waffarha::request('GET', 'units', [
    'page' => 1,
    'per_page' => 20,
]);
```

Available Methods
-----------------

[](#available-methods)

MethodDescription`getUnits(array $queryParameters = [])`Fetch a paginated list of syndicated units.`getUnit(string $uuid)`Retrieve a specific unit by UUID.`request(string $method, string $endpoint, array $data = [])`Send a raw HTTP request to any endpoint.Error Handling
--------------

[](#error-handling)

All API failures throw an `Exception` with a descriptive message and are logged automatically via Laravel's logger:

```
use Maat\Waffarha\Facades\Waffarha;

try {
    $units = Waffarha::getUnits();
} catch (\Exception $e) {
    report($e);
}
```

License
-------

[](#license)

The MIT License (MIT). See [LICENSE](LICENSE) for details.

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance96

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 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 ~0 days

Total

2

Last Release

18d ago

### Community

Maintainers

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

---

Top Contributors

[![bendaryy](https://avatars.githubusercontent.com/u/50684356?v=4)](https://github.com/bendaryy "bendaryy (7 commits)")

### Embed Badge

![Health badge](/badges/maat-waffarha/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3325.1M337](/packages/psalm-plugin-laravel)[renatomarinho/laravel-page-speed

Laravel Page Speed

2.5k1.7M11](/packages/renatomarinho-laravel-page-speed)[illuminate/pipeline

The Illuminate Pipeline package.

9348.3M264](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10533.5M984](/packages/illuminate-pagination)[illuminate/redis

The Illuminate Redis package.

8314.4M356](/packages/illuminate-redis)[spatie/laravel-export

Create a static site bundle from a Laravel app

670139.5k6](/packages/spatie-laravel-export)

PHPackages © 2026

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