PHPackages                             anthonyedmonds/laravel-mysqlite - 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. anthonyedmonds/laravel-mysqlite

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

anthonyedmonds/laravel-mysqlite
===============================

Generate MySQL and Sqlite3 expressions on the fly based on the active database

4.2.2(3w ago)05.7k↓74.6%MITPHPPHP ^8

Since Nov 17Pushed 3w ago1 watchersCompare

[ Source](https://github.com/AnthonyEdmonds/laravel-mysqlite)[ Packagist](https://packagist.org/packages/anthonyedmonds/laravel-mysqlite)[ Docs](https://github.com/AnthonyEdmonds/laravel-mysqlite)[ RSS](/packages/anthonyedmonds-laravel-mysqlite/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (10)Dependencies (15)Versions (24)Used By (0)

Laravel MySqlite
================

[](#laravel-mysqlite)

Generate MySQL and SQLite3 expressions on the fly based on the active database.

Designed primarily for situations where an SQLite3 database is used for testing, but MySQL is used for production.

Calling the `MySqlite::` helper will provide the correct syntax for the default database connection.

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

[](#installation)

1. Install via Composer: `composer require anthonyedmonds/laravel-mysqlite`
2. Use in your code: `use AnthonyEdmonds\LaravelMySqlite\MySqlite`

Usage
-----

[](#usage)

Laravel MySqlite provides syntax for the following MySQL/SQLite conversions:

MySqlite MethodMySQL SyntaxSQLite SyntaxNotesMySqlite::cast()`CAST()``CAST()`Must be a value from `MySqlite::CASTS_MYSQL`MySqlite::concat()`CONCAT()``||`Pass literal strings with quotation marks, such as `'"String"'`MySqlite::concatWs()`CONCAT_WS($separator, ...$columns)``CONCAT_WS($separator, ...$columns)`Concatenate the given columns with a string separatorMySqlite::dateDiff()`DATE_DIFF($from, $to)``JULIANDAY($from) - JULIANDAY($to)`MySqlite::dateFormat()`DATE_FORMAT()``STRFTIME()`Use date formats supported by both MySQL and SQLiteMySqlite::day()`DAY()``STRFTIME()`MySqlite::disableForeignKeys()`SET FOREIGN_KEY_CHECKS=0``PRAGMA foreign_keys = 0`MySqlite::enableForeignKeys()`SET FOREIGN_KEY_CHECKS=1``PRAGMA foreign_keys = 1`MySqlite::groupConcat()`GROUP_CONCAT($columns, $separator)``GROUP_CONCAT($columns, $separator)`Pass literal strings with quotation marks, such as `'"String"'`MySqlite::hour()`HOUR()``STRFTIME()`MySqlite::ifNull()`IFNULL($column, $value)``IFNULL($column, $value)`Pass literal strings with quotation marks, such as `'"String"'`MySqlite::isNull()`IFNULL($column, $value)``IFNULL($column, $value)`Deprecated, to be replaced with ISNULLMySqlite::jsonUnquote()`JSON_UNQUOTE()``TRIM(")`Performs a trim on quotation marksMySqlite::mid()`MID(column, start, length)``SUBSTR(column, start, length)`MySqlite::month()`MONTH()``STRFTIME()`MySqlite::setAutoIncrement()`ALTER TABLE...``UPDATE sqlite_sequence...`Used as a standalone statementMySqlite::trim()`TRIM()``TRIM()`, `LTRIM()`, `RTRIM()`Pass literal strings with quotation marks, such as `'"String"'`MySqlite::weekday()`WEEKDAY(column)``STRFTIME(%u, column) - 1`MySqlite::year()`YEAR()``STRFTIME()`The helper returns an `Expression` with custom `__toString` behaviour, so you may use it directly inside queries:

```
DB::table('users')
    ->select([
        MySqlite::concat(['users.first_name', '" "', 'users.last_name'], 'name'),
        MySqlite::dateFormat('users.created_at', '%d/%m/%Y', 'formatted_date'),
        MySqlite::day('AVG(users.updated_at)', 'aggregated_day'),
        MySqlite::trim('", "', 'users.aliases_list', 'formatted_aliases', MySqlite::TRIM_TRAILING),
    ])
    ->groupBy([
        MySqlite::year('users.updated_at')
    ])
    ->get();
```

### Columns

[](#columns)

The column/columns value of a method accepts a string/array of:

- A column name `'users.first_name'`
- An aggregate method `'COUNT(users.id)'`
- A string literal in quotation marks `'"Literally this"'`
- Any other valid SQL expression

### Aliasing / As

[](#aliasing--as)

The optional `$as` parameter adds a column alias when set:

```
// No alias
MySqlite::hour('users.created_at');
HOUR(users.created_at)

// With alias
MySqlite::hour('users.created_at', 'potato');
HOUR(users.created_at) AS potato
```

Roadmap
-------

[](#roadmap)

There are more syntax differences between MySQL and SQLite that can be compensated for with minor syntax changes, which will be added as they are encountered.

If you require a particular method conversion, raise an issue.

###  Health Score

48

—

FairBetter than 94% of packages

Maintenance94

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

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 ~70 days

Recently: every ~115 days

Total

20

Last Release

27d ago

Major Versions

1.3.2 → 2.0.02023-03-25

2.2.1 → 3.0.02024-04-25

3.2.0 → 4.0.02025-04-16

PHP version history (3 changes)1.0.0PHP ^8

2.0.0PHP ^8.2

3.0.0PHP ^8.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/17785811?v=4)[Anthony Edmonds](/maintainers/AnthonyEdmonds)[@AnthonyEdmonds](https://github.com/AnthonyEdmonds)

---

Top Contributors

[![AnthonyEdmonds](https://avatars.githubusercontent.com/u/17785811?v=4)](https://github.com/AnthonyEdmonds "AnthonyEdmonds (64 commits)")

---

Tags

laraveldatabasemysqlsqlite

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/anthonyedmonds-laravel-mysqlite/health.svg)

```
[![Health](https://phpackages.com/badges/anthonyedmonds-laravel-mysqlite/health.svg)](https://phpackages.com/packages/anthonyedmonds-laravel-mysqlite)
```

###  Alternatives

[illuminate/database

The Illuminate Database package.

2.8k55.8M13.1k](/packages/illuminate-database)[ramadan/custom-fresh

A Laravel package to specify the tables that you do not want to drop while refreshing the database.

613.1k](/packages/ramadan-custom-fresh)[moharrum/laravel-adminer

Adminer database management tool for your Laravel application.

451.0k](/packages/moharrum-laravel-adminer)[ramadan/easy-model

A Laravel package for enjoyably managing database queries.

111.6k](/packages/ramadan-easy-model)

PHPackages © 2026

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