PHPackages                             nathanheffley/laravel-watermelon - 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. [Database &amp; ORM](/categories/database)
4. /
5. nathanheffley/laravel-watermelon

ActiveLibrary[Database &amp; ORM](/categories/database)

nathanheffley/laravel-watermelon
================================

Easily set up a sync endpoint to support Watermelon DB in your Laravel projects.

v3.0.0(1y ago)6521.5k—6.7%16[2 issues](https://github.com/nathanheffley/laravel-watermelon/issues)MITPHPPHP ^8.0

Since Aug 8Pushed 1y ago4 watchersCompare

[ Source](https://github.com/nathanheffley/laravel-watermelon)[ Packagist](https://packagist.org/packages/nathanheffley/laravel-watermelon)[ RSS](/packages/nathanheffley-laravel-watermelon/feed)WikiDiscussions main Synced 1mo ago

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

Laravel Watermelon
==================

[](#laravel-watermelon)

This package provides a [Watermelon DB](https://nozbe.github.io/WatermelonDB/) backend sync implementation for Laravel. Watermelon DB is a robust local database synchronization tool to help develop offline-first application. One of the biggest hurdles is implementing the logic on your server to handle the synchronization process.

That's where this package comes in to provide a quick synchronization route you can get up and running in minutes.

> **This project is still in active development** and does not support schema versions or migrations yet. Both of these are major parts of the Watermelon DB spec. Please expect large changes at least until those features are implemented.

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

[](#installation)

Before getting started you'll need to install the package and publish the config file.

```
composer require nathanheffley/laravel-watermelon

```

```
php artisan vendor:publish --tag="watermelon-config"

```

Usage
-----

[](#usage)

Once you've installed the package, you need to specify which models will be available through the synchronization endpoint. Open up the `config/watermelon.php` file and update the `models` array. The key needs to be the name of table used locally in your application, and the value must be classname of the related model.

You can also change the route to be something other than `/sync` by editing the config file or setting the `WATERMELON_ROUTE` environment variable. You will have to ensure your application makes synchronization requests to whatever route you specify.

By default, only your global middleware will be applied to the synchronization endpoint. This means that unless you changed the default global middleware in your Laravel project the synchronization endpoint will be unauthenticated. If you want to have access to the currently authenticated user you will need to add the `web` middleware to the config file's `middleware` array. If you want to restrict access to the synchronization endpoint to authenticated users only, you can add the `auth` middleware in addition to the `web` middleware. Of course, you can add any middleware you would like as long as it's registered in your project.

```
