MantisDocs

PHP and Laravel

Keep Eloquent and your own migrations. Mantis gives the branch database as plain Postgres, the files as a disk, and branches and rewind.

A Laravel app does not need mantis/schema.ts. It keeps its own migrations and Eloquent and talks to the branch database as plain Postgres. Branches, rewind and files work the same as for any other app.

Set it up

Add shipmantis/mantis with Composer. It comes from the private thealexsan/mantis-php repository, so Composer needs a GitHub token that can read it:

composer config --global github-oauth.github.com "$(gh auth token)"
composer config repositories.mantis vcs https://github.com/thealexsan/mantis-php
composer require shipmantis/mantis:^0.1

Then set the keys:

.env
MANTIS_URL=https://data.shipmantis.com
MANTIS_SECRET_KEY=sk_...
MANTIS_BRANCH=main            # optional

The default database connection becomes the branch database. php artisan migrate migrates it, and Eloquent uses it. Nothing asks Mantis until the first query, and the connection is cached for an hour.

SettingWhat it does
MANTIS_BRANCHThe branch to run on. Make one with npx shipmantis branch create try-it.
MANTIS_DATABASE_HOSThost:port when the app sees Postgres under another name, like a Docker network.
MANTIS_DATABASE=falseLeave the database to your own settings.
MANTIS_DATABASE_DEFAULT=falseAdd a mantis connection without making it the default.

php artisan mantis:connect --dotenv prints the DB_* lines instead, for an app that would rather set them itself. They hold the password, so keep them out of git.

Files

config/filesystems.php
'mantis' => ['driver' => 'mantis'],
Storage::disk('mantis')->put('lessons/intro.mp4', $video);
Storage::disk('mantis')->temporaryUrl('lessons/intro.mp4', now()->addMinutes(5));

Uploads go straight to the bucket in parts; the bucket keys never leave Mantis. A link lasts a few minutes. Who reads a file is set on its folder, on the Files page.

Queries, branches, rewind

use Shipmantis\Mantis\Laravel\Facades\Mantis;

Mantis::table('todos')->insert(['title' => 'Ship it']);
Mantis::branches()->create('try-it');
Mantis::previewRewind(now()->subMinutes(30));

Rewind and migrations

Rewind covers the tables your migrations made and skips Laravel's migrations table. It goes no further back than the last migration or rollback: name a time before one, and it refuses.

On this page