PHPackages                             leafs/db - 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. [Framework](/categories/framework)
4. /
5. leafs/db

ActiveLibrary[Framework](/categories/framework)

leafs/db
========

Leaf PHP db module.

v4.0.2(1y ago)631.8k↓34.7%13[3 issues](https://github.com/leafsphp/db/issues)[1 PRs](https://github.com/leafsphp/db/pulls)6MITPHPCI passing

Since Sep 19Pushed 4w ago2 watchersCompare

[ Source](https://github.com/leafsphp/db)[ Packagist](https://packagist.org/packages/leafs/db)[ Docs](https://leafphp.dev/modules/db/)[ GitHub Sponsors](https://github.com/leafsphp)[ Fund](https://opencollective.com/leaf)[ RSS](/packages/leafs-db/feed)WikiDiscussions v4.x Synced 2d ago

READMEChangelog (10)Dependencies (3)Versions (18)Used By (6)

 [![](https://camo.githubusercontent.com/e83224618735d048f0f70f04e02d7973a634a055e18d47fe22501e3a85e40b9f/68747470733a2f2f6c6561667068702e6e65746c6966792e6170702f6173736574732f696d672f6c656166332d6c6f676f2e706e67)](https://camo.githubusercontent.com/e83224618735d048f0f70f04e02d7973a634a055e18d47fe22501e3a85e40b9f/68747470733a2f2f6c6561667068702e6e65746c6966792e6170702f6173736574732f696d672f6c656166332d6c6f676f2e706e67)

Leaf Db v4
==========

[](#leaf-db-v4)

[![Latest Stable Version](https://camo.githubusercontent.com/795f7c5292b324c8d9b0fcefd9f6d5dd1d7a0ce0a0395c46248afa19f4142f0b/68747470733a2f2f706f7365722e707567782e6f72672f6c656166732f64622f762f737461626c65)](https://packagist.org/packages/leafs/db)[![Total Downloads](https://camo.githubusercontent.com/ed4827e6daafec3f9c1dd273292bf6a00e0580c9304e8720369242f284db94db/68747470733a2f2f706f7365722e707567782e6f72672f6c656166732f64622f646f776e6c6f616473)](https://packagist.org/packages/leafs/db)[![License](https://camo.githubusercontent.com/c5a48b9ef2dad6495bc4f4592c66b84e7e88ee8d447bc590862b011f8a431296/68747470733a2f2f706f7365722e707567782e6f72672f6c656166732f64622f6c6963656e7365)](https://packagist.org/packages/leafs/db)

Leaf DB is a simple, lightweight and easy to use database module for PHP. It gives you a simple interface to connect to your database and perform basic operations like creating tables, inserting data, selecting data and more without the need for complex ORMs or database libraries. Leaf DB is built on top of PDO, so it supports all the features of PDO and is compatible with most databases.

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

[](#installation)

You can easily install Leaf using [Composer](https://getcomposer.org/).

```
leaf install db
# or with composer
composer require leafs/db
```

Basic usage
-----------

[](#basic-usage)

After installing leaf db, you need to connect to your database to use any of the db functions.

```
$db = new Leaf\Db('127.0.0.1', 'dbName', 'user', 'password');

# or

$db = new Leaf\Db();
$db->connect('127.0.0.1', 'dbName', 'user', 'password');
```

If you're using leaf db in a leaf 4 app, you will have access to the `db` global

```
db()->connect('127.0.0.1', 'dbName', 'user', 'password');
```

*This is done automatically if you are using Leaf MVC.*

---

From there, you can use any db method.

```
$users = db()->select('users')->all();
```

Checkout [leaf db's complete documentation](https://leafphp.dev/docs/database/).

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance63

Regular maintenance activity

Popularity36

Limited adoption so far

Community28

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 81.3% 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 ~114 days

Recently: every ~120 days

Total

16

Last Release

28d ago

Major Versions

v1.0 → v2.02022-01-16

2.4.1 → v4.02025-02-25

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/29547806?v=4)[Mychi](/maintainers/Mychi)[@mychi](https://github.com/mychi)

---

Top Contributors

[![mychidarko](https://avatars.githubusercontent.com/u/26604242?v=4)](https://github.com/mychidarko "mychidarko (104 commits)")[![ibnsultan](https://avatars.githubusercontent.com/u/28471267?v=4)](https://github.com/ibnsultan "ibnsultan (9 commits)")[![myteril](https://avatars.githubusercontent.com/u/22733580?v=4)](https://github.com/myteril "myteril (4 commits)")[![MischaKr](https://avatars.githubusercontent.com/u/1812985?v=4)](https://github.com/MischaKr "MischaKr (2 commits)")[![haruspeks](https://avatars.githubusercontent.com/u/146178838?v=4)](https://github.com/haruspeks "haruspeks (2 commits)")[![mieszkou](https://avatars.githubusercontent.com/u/57371264?v=4)](https://github.com/mieszkou "mieszkou (2 commits)")[![terrybr](https://avatars.githubusercontent.com/u/378788?v=4)](https://github.com/terrybr "terrybr (1 commits)")[![Bazowsky](https://avatars.githubusercontent.com/u/10651475?v=4)](https://github.com/Bazowsky "Bazowsky (1 commits)")[![franciscoernestoteixeira](https://avatars.githubusercontent.com/u/1563399?v=4)](https://github.com/franciscoernestoteixeira "franciscoernestoteixeira (1 commits)")[![pakuningratan](https://avatars.githubusercontent.com/u/68019361?v=4)](https://github.com/pakuningratan "pakuningratan (1 commits)")[![apfox](https://avatars.githubusercontent.com/u/427558?v=4)](https://github.com/apfox "apfox (1 commits)")

---

Tags

phpframeworkdatabaseormleaf

###  Code Quality

TestsPest

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/leafs-db/health.svg)

```
[![Health](https://phpackages.com/badges/leafs-db/health.svg)](https://phpackages.com/packages/leafs-db)
```

###  Alternatives

[opulence/opulence

The Opulence PHP framework

71929.0k2](/packages/opulence-opulence)[zemit-cms/core

Build Phalcon REST APIs faster with database-first scaffolding, model relationships, eager loading, identity, permissions, CLI, and WebSocket support.

148.5k1](/packages/zemit-cms-core)[mirekmarek/php-jet

PHP Jet is modern, powerful, real-life proven, really fast and secure, small and light-weight framework for PHP8 with great clean and flexible modular architecture containing awesome developing tools. No magic, just clean software engineering.

241.3k](/packages/mirekmarek-php-jet)

PHPackages © 2026

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