PHPackages                             mnapoli/sqlite-s3 - 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. mnapoli/sqlite-s3

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

mnapoli/sqlite-s3
=================

0.3.2(1y ago)1042.7k↓75%3[1 issues](https://github.com/mnapoli/sqlite-s3/issues)MITPHPPHP &gt;=8.1

Since Dec 14Pushed 1y ago1 watchersCompare

[ Source](https://github.com/mnapoli/sqlite-s3)[ Packagist](https://packagist.org/packages/mnapoli/sqlite-s3)[ GitHub Sponsors](https://github.com/mnapoli)[ RSS](/packages/mnapoli-sqlite-s3/feed)WikiDiscussions main Synced 1mo ago

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

Serverless dev database: SQLite backed by S3
============================================

[](#serverless-dev-database-sqlite-backed-by-s3)

Why?
----

[](#why)

A "serverless" SQL database:

- For development and testing purposes
- Costs $0
- As simple to use as possible
- Ideal for [serverless environments](https://bref.sh/) like AWS Lambda

**Not for production use-cases**. It does not handle concurrent updates (in which case some data might be lost) and performances are not production-grade.

How?
----

[](#how)

The SQLite database (a file) is stored on S3. The PHP class will transparently download the file locally on every request, and upload it back at the end.

This has two obvious implications:

1. If two concurrent requests download the database file, update it (separately), and upload it back, then the last to upload the modified file will overwrite the changes of the other request.
2. There is extra latency added to the request (and it wouldn't work well with huge databases).

That is why this solution is best for testing scenarios (e.g. testing a fully deployed application, where there is one test running at a time). It could also work for development environments with only one active user at a time, where an extra 50ms-100ms per request is acceptable.

Setup
-----

[](#setup)

You will need an AWS S3 bucket (where the database will be stored). The S3 bucket must exist, but **the SQLite database file will automatically be created** if it doesn't.

Install the package with Composer:

```
composer require mnapoli/sqlite-s3
```

Usage
-----

[](#usage)

### With Laravel

[](#with-laravel)

Update `.env` (or set environment variables) to set:

- `DB_CONNECTION=sqlite`
- `DB_DATABASE='s3://the-s3-bucket-name/a-file-name.sqlite'`

The `DB_DATABASE` usually contains a file name, but here it will contain a S3 URL. That URL will be automatically detected to retrieve the database from S3.

The database will be uploaded to S3 on every request. When running on AWS Lambda with Bref, it will be uploaded/synced on every AWS Lambda invocation too.

Outside of Lambda (for example in test code), call `DB::purge();` to force the database to be synced to S3.

### Generic PHP application

[](#generic-php-application)

Instead of:

```
$db = new PDO('sqlite:test-db.sqlite');
$db->exec('SELECT * FROM my-table');
```

Use:

```
$db = new PDOSQLiteS3('the-s3-bucket-name', 'a-file-name.sqlite');
$db->exec('SELECT * FROM my-table');
```

The database will be uploaded back to S3 when the `$db` instance is destroyed (i.e. when the PDO connection is closed).

### Configuration

[](#configuration)

If needed, set the AWS region:

```
$db = new PDOSQLiteS3('the-s3-bucket-name', 'a-file-name.sqlite', [
    'region' => 'us-east-1',
]);
```

The AWS credentials will automatically be picked up by the AWS SDK. The [Async-AWS](https://async-aws.com/) library is used under the hood, check out [its documentation](https://async-aws.com/authentication/).

### Without PDO

[](#without-pdo)

If you are using the [`SQLite3` class](https://www.php.net/manual/en/class.sqlite3.php) directly, replace it with the `SQLiteS3` class:

```
$db = new SQLiteS3('the-s3-bucket-name', 'a-file-name.sqlite');
```

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 94.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 ~74 days

Total

5

Last Release

587d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/329a6111724074f5388e95dd41a03ccf3c43f4bfe1ecf27c94c9efc6f7823228?d=identicon)[mnapoli](/maintainers/mnapoli)

---

Top Contributors

[![mnapoli](https://avatars.githubusercontent.com/u/720328?v=4)](https://github.com/mnapoli "mnapoli (18 commits)")[![aidansteele](https://avatars.githubusercontent.com/u/369053?v=4)](https://github.com/aidansteele "aidansteele (1 commits)")

---

Tags

s3sqlitesqlite-s3s3awssqliteserverless

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/mnapoli-sqlite-s3/health.svg)

```
[![Health](https://phpackages.com/badges/mnapoli-sqlite-s3/health.svg)](https://phpackages.com/packages/mnapoli-sqlite-s3)
```

###  Alternatives

[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k578.4M5.6k](/packages/doctrine-dbal)[scienta/doctrine-json-functions

A set of extensions to Doctrine that add support for json query functions.

58523.9M36](/packages/scienta-doctrine-json-functions)[codesleeve/stapler

Elegant and simple ORM-based file upload package for php.

538366.4k5](/packages/codesleeve-stapler)[bref/laravel-bridge

An advanced Laravel integration for Bref, including Octane support.

3384.1M11](/packages/bref-laravel-bridge)[renoki-co/l1

Laravel integration for Cloudflare Workers services.

16113.1k](/packages/renoki-co-l1)[nemo64/dbal-rds-data

rds-data driver for doctrine dbal

2713.2k](/packages/nemo64-dbal-rds-data)

PHPackages © 2026

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