{"id":18721045,"url":"https://github.com/mauricius/laravel-synchronized-fields","last_synced_at":"2026-04-13T09:32:30.277Z","repository":{"id":66196097,"uuid":"227312277","full_name":"mauricius/laravel-synchronized-fields","owner":"mauricius","description":null,"archived":false,"fork":false,"pushed_at":"2020-01-17T21:07:37.000Z","size":19,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-10T03:24:37.262Z","etag":null,"topics":["json","laravel","laravel-package","php"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mauricius.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-11T08:19:41.000Z","updated_at":"2022-11-03T19:18:46.000Z","dependencies_parsed_at":"2023-03-18T04:01:14.749Z","dependency_job_id":null,"html_url":"https://github.com/mauricius/laravel-synchronized-fields","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mauricius/laravel-synchronized-fields","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mauricius%2Flaravel-synchronized-fields","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mauricius%2Flaravel-synchronized-fields/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mauricius%2Flaravel-synchronized-fields/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mauricius%2Flaravel-synchronized-fields/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mauricius","download_url":"https://codeload.github.com/mauricius/laravel-synchronized-fields/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mauricius%2Flaravel-synchronized-fields/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31746294,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T09:16:15.125Z","status":"ssl_error","status_checked_at":"2026-04-13T09:16:05.023Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["json","laravel","laravel-package","php"],"created_at":"2024-11-07T13:33:23.296Z","updated_at":"2026-04-13T09:32:30.262Z","avatar_url":"https://github.com/mauricius.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Synchronized Fields\n\nThis package targets a very specific need, which is moving long and storage-expensive JSON fields out of the main database to external storage systems, without sacrificing the simplicity and the comfort of Eloquent models.\n\nIt has some limitations, though:\n\n* It works only with Eloquent Models with numeric PKs\n* It does not work with relationships. You cannot use it to persist JSON fields in pivot tables, unless you define a custom Model for them.\n* You will have to set your JSON fields as `nullable`\n\n## Requirements\n\nThis package requires Laravel 5.5 or higher, PHP 7.0 or higher.\n\n## Documentation\n\n### Installation\n\nThe package can be installed via composer:\n\n```\ncomposer require mauricius/laravel-synchronized-fields\n```\n\nThe package will automatically register itself.\n\n### Configuration\n\nYou may publish the configuration file, which will be located at `config/synchronized-fields.php`, using the following command\n\n```\nphp artisan vendor:publish --provider=\"Mauricius\\SynchronizedFields\\SynchronizedFieldsServiceProvider\"\n```\n\n#### Disabling SynchronizedFields\n\nIf you wish to disable the package entirely, you may set the `enabled` key in `config/synchronized-fields.php` to `false`.\n\n#### Set the Storage driver\n\nYou can set the storage driver that will be used to store JSON fields using the `driver` key in `config/synchronized-fields.php`. Available values are:\n\n* `filesystem` (default)\n* `dynamo`\n* `database`\n\n##### Filesystem\n\nThe `filesystem` driver stores JSON fields in one of the [Laravel filesystems](https://laravel.com/docs/6.x/filesystem#configuration) defined in `config/filesystem.php` configuration file. You can set the name of the `disk` instance in the `filesystem.disk` key. In order to simplify management files are splitted between multiple folders, so you may define how many files per folder you want to store using the `files_per_folder` key.\n\n**Note**: make sure to not change this value once you started using this package.\n\n##### DynamoDB\n\nThe `dynamo` driver stores fields in AWS DynamoDB. You need to fill all the required settings in order to connect to the DynamoDB instance.\n \n**Note:** you need to create the tables yourself.\n\n##### Database\n\nThe `database` driver lets you specify an existing database connection from the list of [Laravel connections](https://laravel.com/docs/6.x/database#configuration) defined in the `database.php` configuration file. For example you can store fields in a SQLite Database or in a different MySQL database. \n\n**Note:** you will have to create tables yourself. Just make sure that tables matches the original structure, except of course for the fields that you don't want to synchronize.\n\n#### Replicate\n\nIf you just want to store a copy of each JSON field, instead of removing it from the original source you need to set the `replicate` key to `true`.\n\n### Usage\n\nSimply use the `FieldSynchronizer` trait in the models that you want to synchronize and set the static property for the fields that you want to synchronize.\n\n```php\nuse Mauricius\\SynchronizedFields\\Traits\\SynchronizedFields;\n\nclass Post extends Model\n{\n    use SynchronizedFields;\n\n    /**\n     * The attributes that should be synchronized.\n     *\n     * @var array\n     */\n    protected static $synchronizedFields = [\n        'metadata'\n    ];\n}\n```\nAnd  then use it like this:\n\n```php\n$post = new Post();\n$post-\u003etitle = ...\n\n$post-\u003emetadata = [\n    'key' =\u003e 'value'\n    ...\n];\n\n$post-\u003esave();\n```\n\nThe `metadata` field will be synchronized behind the scenes after saving the model.\n\nThe same works when retrieving the model:\n\n```php\n$post = Post::find(1);\n\n// if $post-\u003emetadata is null in the DB\n// the value will be fetched from the storage\n\ndump($post-\u003emetadata);\n\n// [\n//     'key' =\u003e 'value'\n//     ...\n// ];\n```\n\n#### Skip synchronized fields\n\nIf you want to ignore synchronized fields when using the model you can use the `withoutSynchronizedFields` method.\n\n```php\n$post = Post::withoutSynchronizedFields(function () {\n    return Post::find(1);\n});\n```\n\n#### Skip specific synchronized fields\n\nIf you want instead to ignore only specific synchronized fields when using the model you can use the `ignoringSynchronizedFields` method.\n\n```php\n$post = Post::ignoringSynchronizedFields(['metadata'], function () {\n    return Post::find(1);\n});\n```\n\n## Notes\n\nYou might want to disable entirely the package when testing your application. You can do this by setting the `SYNCHRONIZED_FIELDS_ENABLED` env variable to `false`. For example in `phpunit.xml`\n\n```xml\n\u003cphp\u003e\n    \u003cenv name=\"SYNCHRONIZED_FIELDS_ENABLED\" value=\"false\"/\u003e\n\u003c/php\u003e\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmauricius%2Flaravel-synchronized-fields","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmauricius%2Flaravel-synchronized-fields","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmauricius%2Flaravel-synchronized-fields/lists"}