PHPackages                             splitbrain/php-sqlite - 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. splitbrain/php-sqlite

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

splitbrain/php-sqlite
=====================

A simple wrapper around pdo-sqlite with basic migration support and a few helper utils

1.1.1(1y ago)263MITPHPPHP &gt;=7.4CI passing

Since Mar 15Pushed 1y ago2 watchersCompare

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

READMEChangelogDependencies (1)Versions (4)Used By (0)

PHP SQLite Helper
=================

[](#php-sqlite-helper)

A lightweight PHP library for working with SQLite databases with automatic schema migrations.

This does not replace a full ORM like Doctrine, but it's also like a million times lighter.

Features
--------

[](#features)

- Simple helpers for common SQLite operations
- Automatic schema migrations
- Prepared statement handling
- Enables WAL journal mode, foreign key support and exceptions by default

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

[](#installation)

```
composer require splitbrain/php-sqlite
```

Basic Usage
-----------

[](#basic-usage)

```
use splitbrain\phpsqlite\SQLite;

// Initialize with database file and schema directory
$db = new SQLite('path/to/database.sqlite', 'path/to/migrations');

// Apply any pending migrations
$db->migrate();

// Query data
$contacts = $db->queryAll("SELECT * FROM contacts WHERE name LIKE ?", "%John%");

// Get a single record
$contact = $db->queryRecord("SELECT * FROM contacts WHERE contact_id = ?", 42);

// Get a single value
$count = $db->queryValue("SELECT COUNT(*) FROM contacts");

// Insert or update data
$newContact = $db->saveRecord("contacts", [
    "name" => "John Doe",
    "email" => "john@example.com"
]);

// Execute statements
$db->exec("DELETE FROM contacts WHERE contact_id = ?", 42);
```

Check the [SQLite class](src/SQLite.php) for more methods.

Schema Migrations
-----------------

[](#schema-migrations)

Place your migration files in the schema directory with filenames like:

- `0001.sql` - Initial schema
- `0002.sql` - Add new tables
- `0003.sql` - Add sample data

The library will automatically apply migrations in order when you call `$db->migrate()`.

A table called `opts` is automatically created to track applied migrations. You can also use this table to store configuration values.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance45

Moderate activity, may be stable

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~4 days

Total

3

Last Release

422d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2851a48718937a41d7cc7ea185ec0ad95f3d5e4892e1693ed4f19b08a3f1e4ca?d=identicon)[splitbrain](/maintainers/splitbrain)

---

Top Contributors

[![splitbrain](https://avatars.githubusercontent.com/u/86426?v=4)](https://github.com/splitbrain "splitbrain (10 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/splitbrain-php-sqlite/health.svg)

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

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90440.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)[wildside/userstamps

Laravel Userstamps provides an Eloquent trait which automatically maintains `created\_by` and `updated\_by` columns on your model, populated by the currently authenticated user in your application.

7511.7M13](/packages/wildside-userstamps)

PHPackages © 2026

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