PHPackages                             distinctm/laravel-data-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. distinctm/laravel-data-sync

Abandoned → [nullthoughts/laravel-data-sync](/?search=nullthoughts%2Flaravel-data-sync)Library[Utility &amp; Helpers](/categories/utility)

distinctm/laravel-data-sync
===========================

Laravel utility to keep records synced between environments through source control

v3.0(3y ago)33749[4 issues](https://github.com/nullthoughts/laravel-data-sync/issues)MITPHPPHP ^8.0

Since Jun 12Pushed 1y ago3 watchersCompare

[ Source](https://github.com/nullthoughts/laravel-data-sync)[ Packagist](https://packagist.org/packages/distinctm/laravel-data-sync)[ RSS](/packages/distinctm-laravel-data-sync/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (5)Dependencies (1)Versions (11)Used By (0)

[![Total Downloads](https://camo.githubusercontent.com/ec6a660684c681103c4f49a06f7a178003d5b2743070820886a44d7a268410b3/68747470733a2f2f706f7365722e707567782e6f72672f6e756c6c74686f75676874732f6c61726176656c2d646174612d73796e632f642f746f74616c2e737667)](https://packagist.org/packages/nullthoughts/laravel-data-sync)[![Latest Stable Version](https://camo.githubusercontent.com/3792e66ff159b32614360606eab32660075263d4409b494c79590298586c9519/68747470733a2f2f706f7365722e707567782e6f72672f6e756c6c74686f75676874732f6c61726176656c2d646174612d73796e632f762f737461626c652e737667)](https://packagist.org/packages/nullthoughts/laravel-data-sync)[![Travis CI Build Status: Master](https://camo.githubusercontent.com/d53e95d55e7c0eb7851cec33a0c5bbe9db92144e57feaa6250770848f6f59e1e/68747470733a2f2f6170692e7472617669732d63692e636f6d2f6e756c6c74686f75676874732f6c61726176656c2d646174612d73796e632e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/nullthoughts/laravel-data-sync)

Laravel Data Sync
=================

[](#laravel-data-sync)

Laravel utility to keep records synchronized between environments through source control

[V3.1 branch](https://github.com/nullthoughts/laravel-data-sync/tree/v3.1) Notes (Work in progress)
---------------------------------------------------------------------------------------------------

[](#v31-branch-notes-work-in-progress)

- Adds support for Laravel 8+ models directory in `config/data-sync.php`:

```
'namespace' => '\\App\\Models\\',

```

- Adds ability to export existing Models to data sync files:

```
php artisan data:export User --criteria=name --criteria=email --except=id

```

which generates

```
[
    {
        "_name": "Cameron Frye",
        "properties->title": "Best Friend",
        "phone_numbers->mobile": "555-555-5556",
        "_email": "noreply@buellerandco.com",
    }
]
```

- Further work is required to support remote disks. For testing &amp; development of new V3.1 features, use `composer require nullthoughts/laravel-data-sync:v3.1.x-dev`

---

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

[](#installation)

You can install this package via composer:

```
composer require nullthoughts/laravel-data-sync
```

Or add this line in your `composer.json`, inside of the `require` section:

```
{
    "require": {
        "nullthoughts/laravel-data-sync": "^1.0",
    }
}
```

then run `composer install`

Usage
-----

[](#usage)

- Run `php artisan vendor:publish --provider="nullthoughts\LaravelDataSync\DataSyncBaseServiceProvider" --tag="data-sync-config"` to publish config file. Specify directory for sync data files (default is a new sync directory in the project root)
- Create a JSON file for each model, using the model name as the filename. Example: Product.json would update the Product model
- Use nested arrays in place of hardcoded IDs for relationships
- Run `php artisan data:sync` (or `php artisan data:sync --model={model}` with the model flag to specify a model)

### Optional

[](#optional)

If using Laravel Forge, you can have the data sync run automatically on deploy. Edit your deploy script in Site -&gt; App to include:

```
if [ -f artisan ]
then
    php artisan migrate --force
    php artisan data:sync
fi

```

Notes
-----

[](#notes)

- use studly case for model name relationships as JSON keys (example: 'option\_group' =&gt; 'OptionGroup'). This is important for case sensitive file systems.
- empty values are skipped
- the criteria/attributes for updateOrCreate are identified with a leading underscore
- nested values represent relationships and are returned using where($key, $value)-&gt;first()-&gt;id
- order of import can be set in *config/data-sync.php* with an array:

```
return [
    'path' => base_path('sync'),
    'order' => [
        'Role',
        'Supervisor',
    ]
];

```

Examples
--------

[](#examples)

### User.json:

[](#userjson)

```
[
    {
        "name": "Ferris Bueller",
        "properties->title": "Leisure Consultant",
        "phone_numbers->mobile": "555-555-5555",
        "phone_numbers->office": "",
        "_email": "ferris@buellerandco.com",
        "department": {
            "name": "Management",
            "location": {
                "name": "Chicago"
            }
        }
    }
]
```

translates to...

```
User::updateOrCreate([
    'email' => 'ferris@buellerandco.com',
],[
    'name' => 'Ferris Bueller',
    'properties->title' => 'Leisure Consultant',
    'phone_numbers->mobile' => '555-555-5555',
    'department_id' => Department::where('name', 'Management')
                        ->where('location_id', Location::where('name', 'Chicago')->first()->id)
                        ->first()
                        ->id,
]);
```

### Role.json:

[](#rolejson)

```
[
    {
        "_slug": "update-student-records"
    },
    {
        "_slug": "borrow-ferrari"
    },
    {
        "_slug": "destroy-ferrari"
    }
]
```

translates to...

```
    Role::updateOrCreate(['slug' => 'update-student-records']);

    Role::updateOrCreate(['slug' => 'borrow-ferrari']);

    Role::updateOrCreate(['slug' => 'destroy-ferrari']);
```

### RoleUser.json (pivot table with model):

[](#roleuserjson-pivot-table-with-model)

```
[
    {
        "_user": {
            "email": "ferris@buellerandco.com"
        },
        "_role": {
            "slug": "update-student-records"
        }
    },
    {
        "_user": {
            "email": "ferris@buellerandco.com"
        },
        "_role": {
            "slug": "borrow-ferrari"
        }
    },
    {
        "_user": {
            "email": "ferris@buellerandco.com"
        },
        "_role": {
            "slug": "destroy-ferrari"
        }
    }
]
```

translates to...

```
    RoleUser::updateOrCreate([
        'user_id' => User::where('email', 'ferris@buellerandco.com')->first()->id,
        'role_id' => Role::where('slug', 'update-student-records')->first()->id,
    ]);

    RoleUser::updateOrCreate([
        'user_id' => User::where('email', 'ferris@buellerandco.com')->first()->id,
        'role_id' => Role::where('slug', 'borrow-ferrari')->first()->id,
    ]);

    RoleUser::updateOrCreate([
        'user_id' => User::where('email', 'ferris@buellerandco.com')->first()->id,
        'role_id' => Role::where('slug', 'destroy-ferrari')->first()->id,
    ]);
```

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance28

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 58.7% 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 ~197 days

Recently: every ~225 days

Total

7

Last Release

1340d ago

Major Versions

v1.1.1 → v2.0.02020-03-18

2.1.0 → v3.02022-05-17

PHP version history (3 changes)v2.0.0PHP ^7.2

2.1.0PHP ^7.2|^8.0

v3.0PHP ^8.0

### Community

Maintainers

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

---

Top Contributors

[![nullthoughts](https://avatars.githubusercontent.com/u/11416468?v=4)](https://github.com/nullthoughts "nullthoughts (61 commits)")[![ivuorinen](https://avatars.githubusercontent.com/u/11024?v=4)](https://github.com/ivuorinen "ivuorinen (19 commits)")[![vicgonvt](https://avatars.githubusercontent.com/u/7350307?v=4)](https://github.com/vicgonvt "vicgonvt (18 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (5 commits)")[![atefBB](https://avatars.githubusercontent.com/u/10966925?v=4)](https://github.com/atefBB "atefBB (1 commits)")

---

Tags

data-synclaravel

### Embed Badge

![Health badge](/badges/distinctm-laravel-data-sync/health.svg)

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

###  Alternatives

[aimeos/aimeos-base

Aimeos base layer for abstracting from host environments

2.1k134.0k1](/packages/aimeos-aimeos-base)[microweber/screen

A PHP Class to interact with PhantomJs and capture screenshot of a webpage

632226.0k1](/packages/microweber-screen)[fuel/docs

FuelPHP 1.x Documenataion

166542.3k4](/packages/fuel-docs)[php-soap/ext-soap-engine

An ext-soap engine implementation

443.2M7](/packages/php-soap-ext-soap-engine)[ec-europa/toolkit

Toolkit packaged for Drupal projects based on Robo.

38244.6k16](/packages/ec-europa-toolkit)[fof/user-directory

The permission based public user directory extension for your Flarum forum.

2789.7k5](/packages/fof-user-directory)

PHPackages © 2026

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