PHPackages                             getimmutable/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. getimmutable/laravel

ActiveLibrary[API Development](/categories/api)

getimmutable/laravel
====================

Laravel SDK for the Immutable audit log API.

0.1.0(3mo ago)00MITPHPPHP ^8.2

Since Mar 26Pushed 2mo agoCompare

[ Source](https://github.com/umarey/getimmutable-laravel)[ Packagist](https://packagist.org/packages/getimmutable/laravel)[ RSS](/packages/getimmutable-laravel/feed)WikiDiscussions main Synced 3w ago

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

Immutable Laravel SDK
=====================

[](#immutable-laravel-sdk)

Laravel SDK for the [Immutable](https://getimmutable.com) audit log API.

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

[](#installation)

```
composer require getimmutable/laravel
```

The package auto-discovers its service provider. Publish the config file:

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

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

[](#configuration)

Add the following to your `.env` file:

```
GETIMMUTABLE_API_KEY=your-api-key
GETIMMUTABLE_BASE_URL=https://api.getimmutable.com
GETIMMUTABLE_ASYNC=true
```

VariableDefaultDescription`GETIMMUTABLE_API_KEY`—Your Immutable API key`GETIMMUTABLE_BASE_URL``https://api.getimmutable.com`API base URL`GETIMMUTABLE_ASYNC``true`Dispatch events via queue jobQueue Configuration
-------------------

[](#queue-configuration)

> **Important:** Async mode (the default) dispatches events to the `getimmutable` queue. If your queue worker is not processing this queue, events will silently sit in the queue and never be sent.

Make sure your queue worker includes the `getimmutable` queue:

```
php artisan queue:work --queue=getimmutable,default
```

Or if you use Laravel Horizon, add a supervisor entry in `config/horizon.php`:

```
'environments' => [
    'production' => [
        'supervisor-getimmutable' => [
            'connection' => 'redis',
            'queue' => ['getimmutable'],
            'minProcesses' => 1,
            'maxProcesses' => 3,
            'balanceMaxShift' => 1,
            'balanceCooldown' => 3,
            'tries' => 3,
        ],
    ],
],
```

For local development or testing, set `GETIMMUTABLE_ASYNC=false` to send events synchronously (no queue required).

Usage
-----

[](#usage)

### Raw Payload

[](#raw-payload)

```
use GetImmutable\AuditLog;

AuditLog::track([
    'actor_id' => 'usr_123',
    'action' => 'project.created',
    'resource' => 'Project',
    'resource_id' => 'prj_456',
    'metadata' => ['ip' => request()->ip()],
]);
```

### Fluent Builder (from Auth)

[](#fluent-builder-from-auth)

```
use GetImmutable\AuditLog;

// Uses the currently authenticated user as the actor
AuditLog::fromAuth()->track('project.created', $project, [
    'ip' => request()->ip(),
]);
```

### Fluent Builder (explicit Actor)

[](#fluent-builder-explicit-actor)

```
use GetImmutable\AuditLog;

AuditLog::actor($user)->track('invoice.paid', $invoice, [
    'amount' => 9900,
]);
```

### Resource Handling

[](#resource-handling)

The `track()` method on the builder accepts three resource types:

- **Eloquent Model** — auto-extracts `resource`, `resource_id`, and `resource_name` (via optional `getAuditName()` method)
- **String** — treated as the resource type name (e.g. `'Project'`)
- **null** — no resource fields are included

```
// Eloquent model
AuditLog::fromAuth()->track('project.deleted', $project);

// Plain string
AuditLog::fromAuth()->track('report.exported', 'Report');

// No resource
AuditLog::fromAuth()->track('user.logged_in');
```

### Batch Events

[](#batch-events)

```
use GetImmutable\AuditLog;

AuditLog::trackBatch([
    ['actor_id' => 'usr_1', 'action' => 'item.created'],
    ['actor_id' => 'usr_2', 'action' => 'item.updated'],
]);
```

Automatic Eloquent Tracking
---------------------------

[](#automatic-eloquent-tracking)

Add the `TracksEvents` trait to any Eloquent model to automatically track `created`, `updated`, and `deleted` events:

```
use GetImmutable\Concerns\TracksEvents;
use Illuminate\Database\Eloquent\Model;

class Project extends Model
{
    use TracksEvents;
}
```

Customize which events to track:

```
class Project extends Model
{
    use TracksEvents;

    protected static array $trackedEvents = ['created', 'deleted'];
}
```

Events are recorded as `project.created`, `project.updated`, `project.deleted` (lowercased model name + event).

Testing
-------

[](#testing)

In your test suite, you can either:

1. Set `GETIMMUTABLE_ASYNC=false` and use `Http::fake()` to intercept API calls
2. Set `GETIMMUTABLE_ASYNC=true` and use `Queue::fake()` to assert jobs were dispatched

```
use GetImmutable\AuditLog;
use GetImmutable\Jobs\SendAuditLogEvent;
use Illuminate\Support\Facades\Queue;

Queue::fake();

AuditLog::track(['actor_id' => 'test', 'action' => 'test.action']);

Queue::assertPushed(SendAuditLogEvent::class);
```

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance83

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity36

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

91d ago

### Community

Maintainers

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

---

Top Contributors

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

### Embed Badge

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

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

815320.5k3](/packages/defstudio-telegraph)[simplestats-io/laravel-client

Analytics for Laravel. Track visitors, registrations, and payments. Discover which channels actually drive revenue, not just traffic. Server-side, GDPR compliant, ad-blocker proof.

5019.3k](/packages/simplestats-io-laravel-client)[jasara/php-amzn-selling-partner-api

A fluent interface for Amazon's Selling Partner API in PHP

1348.1k1](/packages/jasara-php-amzn-selling-partner-api)

PHPackages © 2026

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