PHPackages                             nikserg/laravel-api-model - 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. nikserg/laravel-api-model

ActiveLibrary[API Development](/categories/api)

nikserg/laravel-api-model
=========================

Allows to create pseudo-Eloquent models, which are fetched via API from remote server

1.0.5(3y ago)091PHPPHP ^8.1

Since Aug 11Pushed 3y ago2 watchersCompare

[ Source](https://github.com/nikserg/laravel-api-model)[ Packagist](https://packagist.org/packages/nikserg/laravel-api-model)[ RSS](/packages/nikserg-laravel-api-model/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (2)Versions (16)Used By (0)

laravel-api-model
=================

[](#laravel-api-model)

Allows to create pseudo-Eloquent models, which are fetched via API from remote server

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

[](#installation)

`composer require nikserg/laravel-api-model`

In `config/database.php` add

```
return [
    ...
    'connections' => [
        ...
        'api_fruits' => [
            'driver'  => 'api',
            'baseUri' => env('API_FRUITS_HOST', 'https://fruits.com/v1'),
            'verify'  => false,
        ],
    ...
    ],
    ...
];
```

Usage
-----

[](#usage)

```
use nikserg\LaravelApiModel\ApiModel;
class Banana extends ApiModel
{
    protected $connection = 'api_fruits';
    protected $table = 'bananas';
}
```

And then all Eloquent functions are available as usual.

### Authorization

[](#authorization)

If remote server requires some sort of HTTP-authorization (for ex. JWT-token), you need to pass `configuratorClass` parameter to config. This must be a FQDN of class implementing `\nikserg\LaravelApiModel\GuzzleConfigurator` interface. `modifyConfig` method of this class will be called before first request, so it can modify array, which would be passed to `new \GuzzleHttp\Client($config)`.

Example of such config:

```
'api_fruits' => [
    'driver'       => 'api',
    'baseUri'      => 'baseUri' => env('API_FRUITS_HOST', 'https://fruits.com/v1'),
    'verify'       => false,
    'configurator' => \App\Models\GuzzleConfigurator::class,
],
```

Example of class (JWT-token authorization):

```
class GuzzleConfigurator implements \nikserg\LaravelApiModel\GuzzleConfigurator
{
    public static function modifyConfig(array $config): array
    {
        $user = auth()->user();
        $config['headers'] = [
            'Authorization' => 'Bearer ' . $user->getJwtToken(),
        ];
        return $config;
    }
}
```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 83.9% 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 ~3 days

Total

6

Last Release

1349d ago

### Community

Maintainers

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

---

Top Contributors

[![zadrogg](https://avatars.githubusercontent.com/u/62801553?v=4)](https://github.com/zadrogg "zadrogg (26 commits)")[![nikserg](https://avatars.githubusercontent.com/u/5680589?v=4)](https://github.com/nikserg "nikserg (4 commits)")[![dubenko](https://avatars.githubusercontent.com/u/1576083?v=4)](https://github.com/dubenko "dubenko (1 commits)")

### Embed Badge

![Health badge](/badges/nikserg-laravel-api-model/health.svg)

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

###  Alternatives

[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k7.6M74](/packages/openai-php-laravel)[statamic/cms

The Statamic CMS Core Package

4.8k3.2M720](/packages/statamic-cms)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[nickurt/laravel-postcodeapi

Universal PostcodeApi for Laravel 11.x/12.x/13.x

97221.2k](/packages/nickurt-laravel-postcodeapi)[mozex/anthropic-laravel

Anthropic PHP for Laravel is a supercharged PHP API client that allows you to interact with the Anthropic API

71226.4k1](/packages/mozex-anthropic-laravel)[scriptdevelop/whatsapp-manager

Paquete para manejo de WhatsApp Business API en Laravel

762.6k](/packages/scriptdevelop-whatsapp-manager)

PHPackages © 2026

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