PHPackages                             mjducharme/laravel-model-json-storage - 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. [File &amp; Storage](/categories/file-storage)
4. /
5. mjducharme/laravel-model-json-storage

ActiveLibrary[File &amp; Storage](/categories/file-storage)

mjducharme/laravel-model-json-storage
=====================================

Storing your models in a json file rather than in database (single or few lines recording) can be a good option. This package saves you to create a table for a ridiculous amount of lines, improves the data recovery performances, and allows you to store and access to your models from a json files as you would do it in database.

1.0.5(4y ago)11792MITPHPPHP &gt;=7.0

Since Mar 4Pushed 4y agoCompare

[ Source](https://github.com/mjducharme/laravel-model-json-storage)[ Packagist](https://packagist.org/packages/mjducharme/laravel-model-json-storage)[ Docs](https://github.com/mjducharme/laravel-model-json-storage)[ RSS](/packages/mjducharme-laravel-model-json-storage/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (2)Versions (7)Used By (0)

laravel-model-json-storage
==========================

[](#laravel-model-json-storage)

[![Source Code](https://camo.githubusercontent.com/2ea501de8864a2313b5c91649a070b9bc26e014b083925290b1afa09d3603fa4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f736f757263652d6d6a6475636861726d652f6c61726176656c2d2d6d6f64656c2d2d6a736f6e2d2d73746f726167652d626c75652e737667)](https://github.com/mjducharme/laravel-model-json-storage)[![Latest Version](https://camo.githubusercontent.com/37b2de9ea813b352936756b8dac4378be13136da8b6849413e875a4106c90c78/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6d6a6475636861726d652f6c61726176656c2d6d6f64656c2d6a736f6e2d73746f726167652e7376673f7374796c653d666c61742d737175617265)](https://github.com/mjducharme/laravel-model-json-storage/releases)[![Total Downloads](https://camo.githubusercontent.com/b3052b8d886225f6cc6022a4e5550b826d2b39008bcaf0b6b3d7525e275a9e84/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6a6475636861726d652f6c61726176656c2d6d6f64656c2d6a736f6e2d73746f726167652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mjducharme/laravel-model-json-storage)[![License: MIT](https://camo.githubusercontent.com/08cef40a9105b6526ca22088bc514fbfdbc9aac1ddbf8d4e6c750e3a88a44dca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c75652e737667)](https://opensource.org/licenses/MIT)[![Build Status](https://camo.githubusercontent.com/29faa2927f5969f588ddec036a00b9195781b525fa9f95a613de0e75bb60403c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d6a6475636861726d652f6c61726176656c2d6d6f64656c2d6a736f6e2d73746f726167652f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mjducharme/laravel-model-json-storage/build-status/master)[![Code Coverage](https://camo.githubusercontent.com/d9025c8c342929d180435dcb5aa1b92e7d3e668227d155c2e53399644ff3a8e6/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d6a6475636861726d652f6c61726176656c2d6d6f64656c2d6a736f6e2d73746f726167652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mjducharme/laravel-model-json-storage/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/f1c26e73e0ca2af0d14a8f71a83a6909074896b2863be2baebd63e5fec079c11/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d6a6475636861726d652f6c61726176656c2d6d6f64656c2d6a736f6e2d73746f726167652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mjducharme/laravel-model-json-storage/?branch=master)

Forked from Okipa/laravel-model-json-storage

Storing your models in a json file rather than in database (single or few lines recording) can be a good option.
This package saves you to create a table for a ridiculous amount of lines, improves the data recovery performances, and allows you to store and access to your models from a json files as you would do it in database.

---

To read before use
------------------

[](#to-read-before-use)

Please keep in mind that :

- The purpose of this package is to store your model instances in json.
- Consequently, the json file is always entirely read when you access to your data
- Consequently, you should **NOT** use this package if you have a lot of instances to store, it could cause performance issues rather than improve it.
- All the query-related and model-related functionalities are not available (especially those which use database), this package has been made for quite simple use cases.
- This package enables you to manipulate models as if it they would been stored in database but it always uses the [Illuminate\\Support\\Collection methods](https://laravel.com/docs/5.4/collections) methods under the hood.

---

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

[](#installation)

- Install the package with composer :

```
composer require mjducharme/laravel-model-json-storage
```

- Laravel 5.5+ uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider. If you don't use auto-discovery or if you use a Laravel 5.0- version, add the package service provider in the `register()` method from your `app/Providers/AppServiceProvider.php` :

```
// laravel model json storage
// https://github.com/mjducharme/laravel-model-json-storage
$this->app->register(Okipa\LaravelModelJsonStorage\ModelJsonStorageServiceProvider::class);
```

---

Usage
-----

[](#usage)

First, add the `ModelJsonStorage` trait in your model.

```
class MyTestModel extends Illuminate\Database\Eloquent\Model
{
    use Okipa\LaravelModelJsonStorage\ModelJsonStorage;

    [...]
}
```

Then, just manipulate your model normally.
After a storage, you will see a json file named with your model title in the path defined in the `model-json-storage` config file.

```
$testModel = app(MyTestModel::class)->create([
    'name' => 'John Doe',
    'email' => 'john@doe.com',
    'password' => Hash::make('secret'),
]);
```

```
$testModel = app(MyTestModel::class)->all();
```

```
$testModel = app(MyTestModel::class)->where('email', 'john@doe.com')->first();
```

```
$testModel->update([
    'name' => 'Gary Cook'
]);
```

```
$testModel->delete();
```

---

Customize configuration
-----------------------

[](#customize-configuration)

To personalize the package configuration, you have to publish it first with the following script :

```
php artisan vendor:publish --tag=model-json-storage::config
```

Then, open the published package configuration file (`config/model-json-storage.php`) and override the default configuration by setting your own values for the following items :

- json storage path
- ... that's all for now.

---

API
---

[](#api)

The most used query-related and model-related methods have been overridden to allow you to use your json stored model as usual.
Retrieve the list of the available methods bellow.
However, if you want to add a method for your personal needs, do not hesitate to improve this package with a PR.

### Available Illuminate\\Database\\Eloquent\\Model methods

[](#available-illuminatedatabaseeloquentmodel-methods)

- [save()](https://laravel.com/api/5.8/Illuminate/Database/Eloquent/Model.html#method_save)
- [update()](https://laravel.com/api/5.8/Illuminate/Database/Eloquent/Model.html#method_update)
- [delete()](https://laravel.com/api/5.8/Illuminate/Database/Eloquent/Model.html#method_delete)
- [all()](https://laravel.com/api/5.8/Illuminate/Database/Eloquent/Model.html#method_all)

### Available Illuminate\\Database\\Query\\Builder methods

[](#available-illuminatedatabasequerybuilder-methods)

- [get()](https://laravel.com/api/5.8/Illuminate/Database/Query/Builder.html#method_get)
- [Select()](https://laravel.com/api/5.8/Illuminate/Database/Query/Builder.html#method_select)
- [addSelect()](https://laravel.com/api/5.8/Illuminate/Database/Query/Builder.html#method_addSelect)
- [where()](https://laravel.com/api/5.8/Illuminate/Database/Query/Builder.html#method_where)
- [whereNull()](https://laravel.com/api/5.8/Illuminate/Database/Query/Builder.html#method_whereNull)
- [whereNotNull()](https://laravel.com/api/5.8/Illuminate/Database/Query/Builder.html#method_whereNotNull)
- [orderBy()](https://laravel.com/api/5.8/Illuminate/Database/Query/Builder.html#method_orderBy)
- [orderByDesc()](https://laravel.com/api/5.8/Illuminate/Database/Query/Builder.html#method_orderByDesc)
- [whereIn()](https://laravel.com/api/5.8/Illuminate/Database/Query/Builder.html#method_whereIn)
- [whereNotIn()](https://laravel.com/api/5.8/Illuminate/Database/Query/Builder.html#method_whereNotIn)
- [find()](https://laravel.com/api/5.8/Illuminate/Database/Query/Builder.html#method_find)
- [findOrFail()](https://laravel.com/api/5.8/Illuminate/Database/Eloquent/Builder.html#method_findOrFail)
- [paginate()](https://laravel.com/api/5.8/Illuminate/Database/Query/Builder.html#method_paginate)
- [value()](https://laravel.com/api/5.8/Illuminate/Database/Query/Builder.html#method_value)
- [pluck()](https://laravel.com/api/5.8/Illuminate/Database/Query/Builder.html#method_pluck)
- [count()](https://laravel.com/api/5.8/Illuminate/Database/Query/Builder.html#method_count)
- [min()](https://laravel.com/api/5.8/Illuminate/Database/Query/Builder.html#method_min)
- [max()](https://laravel.com/api/5.8/Illuminate/Database/Query/Builder.html#method_max)
- [avg()](https://laravel.com/api/5.8/Illuminate/Database/Query/Builder.html#method_avg)

### Available Illuminate\\Database\\Concerns\\BuildsQueries methods

[](#available-illuminatedatabaseconcernsbuildsqueries-methods)

- [first()](https://laravel.com/api/5.8/Illuminate/Database/Concerns/BuildsQueries.html#method_first)

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 58.8% 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 ~249 days

Recently: every ~309 days

Total

6

Last Release

1747d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1851874?v=4)[Michael Ducharme](/maintainers/mjducharme)[@mjducharme](https://github.com/mjducharme)

---

Top Contributors

[![Okipa](https://avatars.githubusercontent.com/u/5328934?v=4)](https://github.com/Okipa "Okipa (20 commits)")[![mjducharme](https://avatars.githubusercontent.com/u/1851874?v=4)](https://github.com/mjducharme "mjducharme (14 commits)")

---

Tags

phpjsonlaravelpackagemodelstorageokipa

### Embed Badge

![Health badge](/badges/mjducharme-laravel-model-json-storage/health.svg)

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

###  Alternatives

[okipa/laravel-table

Generate tables from Eloquent models.

56752.8k](/packages/okipa-laravel-table)[okipa/laravel-form-components

Ready-to-use and customizable form components.

198.0k1](/packages/okipa-laravel-form-components)

PHPackages © 2026

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