Download the PHP package mnapoli/sqlite-s3 without Composer

On this page you can find all versions of the php package mnapoli/sqlite-s3. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package sqlite-s3

Serverless dev database: SQLite backed by S3

Why?

A "serverless" SQL database:

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?

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

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:

Usage

With Laravel

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

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

Instead of:

Use:

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

Configuration

If needed, set the AWS region:

The AWS credentials will automatically be picked up by the AWS SDK. The Async-AWS library is used under the hood, check out its documentation.

Without PDO

If you are using the SQLite3 class directly, replace it with the SQLiteS3 class:


All versions of sqlite-s3 with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
ext-pdo Version *
ext-sqlite3 Version *
async-aws/simple-s3 Version ^1|^2
bref/bref Version ^2.1.10
bref/logger Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mnapoli/sqlite-s3 contains the following files

Loading the files please wait ....