PHPackages                             madbox-99/laravel-user-team-sync - 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. madbox-99/laravel-user-team-sync

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

madbox-99/laravel-user-team-sync
================================

User and team synchronization between a subscriber hub and secondary Laravel apps

v1.3.0(2mo ago)0188—0%MITPHPPHP ^8.3

Since Feb 10Pushed 1mo agoCompare

[ Source](https://github.com/MadBox-99/laravel-user-team-sync)[ Packagist](https://packagist.org/packages/madbox-99/laravel-user-team-sync)[ RSS](/packages/madbox-99-laravel-user-team-sync/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (4)Versions (7)Used By (0)

Laravel User Team Sync
======================

[](#laravel-user-team-sync)

Laravel package for synchronizing users and teams across multiple Laravel applications using a Publisher/Receiver pattern.

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

[](#requirements)

- PHP 8.3+
- Laravel 11 or 12

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

[](#installation)

```
composer require madbox-99/laravel-user-team-sync
```

Then run the install command:

```
php artisan user-team-sync:install
```

This will:

- Ask for your sync mode (publisher/receiver/both)
- Generate or accept an API key
- Update your `.env` file
- Publish the config and migration files
- Optionally run migrations

### Manual Installation

[](#manual-installation)

If you prefer to install manually:

```
php artisan vendor:publish --tag=user-team-sync-config
php artisan vendor:publish --tag=user-team-sync-migrations
php artisan migrate
```

Then add these to your `.env`:

```
USER_TEAM_SYNC_MODE=receiver
USER_TEAM_SYNC_API_KEY=your-secret-key
```

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

[](#configuration)

### Modes

[](#modes)

ModeDescription`publisher`Sends sync events to other apps`receiver`Receives sync events from a publisher`both`Sends and receives### Publisher Setup

[](#publisher-setup)

Set mode to `publisher`. Receiver apps can be stored in the **config file** or in the **database**.

#### Option A: Config-based apps (default)

[](#option-a-config-based-apps-default)

Define apps in `config/user-team-sync.php`:

```
'publisher' => [
    'app_source' => 'config', // default
    'api_key' => env('USER_TEAM_SYNC_API_KEY'),
    'apps' => [
        'crm' => [
            'url' => env('CRM_APP_URL'),
            'api_key' => env('CRM_APP_API_KEY'), // optional, falls back to default
            'active' => true,
        ],
        'shop' => [
            'url' => env('SHOP_APP_URL'),
            'api_key' => env('SHOP_APP_API_KEY'),
            'active' => true,
        ],
    ],
],
```

#### Option B: Database-based apps (recommended)

[](#option-b-database-based-apps-recommended)

Store apps in the `sync_apps` table for dynamic management:

```
USER_TEAM_SYNC_APP_SOURCE=database
```

The install command (`php artisan user-team-sync:install`) can set this up interactively, or you can manage apps manually:

```
use Madbox99\UserTeamSync\Models\SyncApp;

// Add a new app
SyncApp::create([
    'name' => 'crm',
    'url' => 'https://crm.example.com',
    'api_key' => 'secret-key', // stored encrypted
    'is_active' => true,
]);

// Deactivate an app
SyncApp::where('name', 'crm')->update(['is_active' => false]);
```

> API keys are stored using Laravel's `encrypted` cast. Make sure your `APP_KEY` is set.

### Receiver Setup

[](#receiver-setup)

Set mode to `receiver` and configure the API key:

```
'receiver' => [
    'api_key' => env('USER_TEAM_SYNC_API_KEY'),
    'route_prefix' => 'api',
    'role_driver' => 'spatie',
    'default_role' => 'subscriber',
    'default_active' => false,
],
```

> The receiver API key must match the publisher's key for that app.

Usage
-----

[](#usage)

### Automatic Sync (Observer)

[](#automatic-sync-observer)

When `auto_observe` is enabled (default), the package automatically watches your User model for changes to configured fields (`email`, `role` by default) and syncs them to all active receiver apps.

```
// This automatically triggers sync to all receiver apps
$user->update(['role' => 'admin']);
```

### Manual Sync via Facade

[](#manual-sync-via-facade)

```
use Madbox99\UserTeamSync\Facades\UserTeamSync;

// Create a user on all receiver apps
UserTeamSync::createUser(
    email: 'john@example.com',
    name: 'John Doe',
    password: 'plain-text-password', // hashed automatically before sending
    role: 'editor',
    ownerEmail: 'owner@example.com',
);

// Sync user changes
UserTeamSync::syncUser('john@example.com', [
    'new_email' => 'john.doe@example.com',
    'role' => 'admin',
]);

// Create a team on all receiver apps
UserTeamSync::createTeam(
    teamName: 'Marketing',
    userEmail: 'john@example.com',
    slug: 'marketing', // optional, auto-generated from name
);

// Toggle user active status on a specific app
UserTeamSync::toggleUserActive(
    userEmail: 'john@example.com',
    isActive: true,
    appKey: 'crm',
);
```

API Endpoints (Receiver)
------------------------

[](#api-endpoints-receiver)

All endpoints are protected by Bearer token authentication.

MethodEndpointDescriptionPOST`/api/create-user`Create a new userPOST`/api/sync-user`Update user fieldsPOST`/api/toggle-user-active`Set active/inactive statusPOST`/api/create-team`Create a teamGET`/api/user-teams`Get user's teamsPOST`/api/sync-password`Sync password hashEvents
------

[](#events)

Listen to these events for custom logic:

EventWhen`UserCreatedFromSync`User created on receiver`UserSynced`User fields updated`PasswordSynced`Password synced to receiver`UserActiveToggled`Active status changed`TeamCreatedFromSync`Team created on receiver`SyncFailed`Any sync operation failed```
// In EventServiceProvider or listener
use Madbox99\UserTeamSync\Events\UserCreatedFromSync;

class HandleSyncedUser
{
    public function handle(UserCreatedFromSync $event): void
    {
        // $event->user
    }
}
```

Logging
-------

[](#logging)

All sync operations are logged to the `sync_logs` table. Configure in `config/user-team-sync.php`:

```
'logging' => [
    'enabled' => true,
    'table' => 'sync_logs',
    'retention_days' => 30,
],
```

Environment Variables
---------------------

[](#environment-variables)

VariableDescriptionDefault`USER_TEAM_SYNC_MODE`Sync mode`receiver``USER_TEAM_SYNC_API_KEY`API key for authentication—`USER_TEAM_SYNC_APP_SOURCE`App storage: `config` or `database``config``USER_TEAM_SYNC_USER_MODEL`User model class`App\Models\User``USER_TEAM_SYNC_TEAM_MODEL`Team model class`App\Models\Team``USER_TEAM_SYNC_QUEUE`Queue name for jobs`default``USER_TEAM_SYNC_QUEUE_CONNECTION`Queue connection`null``USER_TEAM_SYNC_TRIES`Job retry attempts`3``USER_TEAM_SYNC_BACKOFF`Seconds between retries`60``USER_TEAM_SYNC_TIMEOUT`HTTP timeout in seconds`10`Testing
-------

[](#testing)

```
vendor/bin/pest
```

License
-------

[](#license)

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

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance87

Actively maintained with recent releases

Popularity15

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity53

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

6

Last Release

89d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c5c06d300b54123eef43d008b7e0c35ce6b21aa57dd1cb83ec1aefc7a3b69772?d=identicon)[MadBox-99](/maintainers/MadBox-99)

---

Top Contributors

[![MadBox-99](https://avatars.githubusercontent.com/u/72586295?v=4)](https://github.com/MadBox-99 "MadBox-99 (17 commits)")

---

Tags

laraveluserwebhooksyncTeamMicroservice

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/madbox-99-laravel-user-team-sync/health.svg)

```
[![Health](https://phpackages.com/badges/madbox-99-laravel-user-team-sync/health.svg)](https://phpackages.com/packages/madbox-99-laravel-user-team-sync)
```

###  Alternatives

[livewire/volt

An elegantly crafted functional API for Laravel Livewire.

4195.3M84](/packages/livewire-volt)[gitscrum-community-edition/laravel-gitscrum

GitScrum is a project to help developer team. Git + Scrum = Team More Productive

2.9k2.0k](/packages/gitscrum-community-edition-laravel-gitscrum)[zachleigh/laravel-property-bag

Easy Laravel user settings using a property bag

85340.3k](/packages/zachleigh-laravel-property-bag)[forxer/laravel-gravatar

A library providing easy gravatar integration in a Laravel project.

4235.6k](/packages/forxer-laravel-gravatar)[iteks/laravel-enum

A comprehensive Laravel package providing enhanced enum functionalities, including attribute handling, select array conversions, and fluent facade interactions for robust enum management in Laravel applications.

2516.7k](/packages/iteks-laravel-enum)[shipsaas/laravel-inbox-process

Inbox pattern process implementation for your Laravel Applications

132.1k](/packages/shipsaas-laravel-inbox-process)

PHPackages © 2026

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