PHPackages                             tesis/db-layer - 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. tesis/db-layer

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

tesis/db-layer
==============

Simple DB layer for mysqli extension and PDO class. It is based on mappers, files holding database table fields, primary key and auto\_increment properties, which is helpful to compare fields for CRUD or select operations, and to provide better way to prevent SQL injections (only existing fields are selected, or inserted, ...)

012PHP

Since May 9Pushed 8y ago1 watchersCompare

[ Source](https://github.com/tesis/db-layer)[ Packagist](https://packagist.org/packages/tesis/db-layer)[ RSS](/packages/tesis-db-layer/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

DBLayer, PHP ORM
================

[](#dblayer-php-orm)

DB layers for mysqli extension and PDO class. DBLayer is working with mappers (files holding tables' properties) to provide safer SQL operations.

Installing DBLayer
------------------

[](#installing-dblayer)

The recommended way to install DBLayer is through [Composer](http://getcomposer.org).

```
# Install Composer
curl -sS https://getcomposer.org/installer | php
```

Next, run the Composer command to install the latest stable version of DBLayer:

```
composer require tesis/db-layer

# Add scripts to composer json:
"scripts": {
    "post-update-cmd": "DBLayer\\Loader::postUpdate",
    "post-install-cmd": "DBLayer\\Loader::postInstall"
}
```

or insert in your composer:

```
"require": {
    "tesis/db-layer": "1.0.x-dev"
},
"require-dev": {
    "phpunit/phpunit": "^6.5"
},

"scripts": {
    "post-update-cmd": "DBLayer\\Loader::postUpdate",
    "post-install-cmd": "DBLayer\\Loader::postInstall"
}

# Run: composer update / composer install
```

After installing, you need to require Composer's autoloader:

```
require 'vendor/autoload.php';
```

You can then later update DBLayer using composer:

```
composer update
```

DB Layer - ORM
==============

[](#db-layer---orm)

> migrate sql files (simple SQL, see folders db/migrations, db/seeders)

> generate database mapper (default - json format, optional (.ini file, or .php file returning an array) (examples of generated files are in tests/data folder)

> for CRUD or select statements, provided two layers: mysqli and PDO

> Start with

```
# Change database credentials, write env.ini file
php vendor/tesis/db-layer/init
```

Credentials
-----------

[](#credentials)

add/change credentials in config/dbLayer.php file

Migrate
-------

[](#migrate)

if you database and / or tables are not yet created, create them manually or prepare simple migration and seeder file (examples in database/migrations and database/seeders dir)

```
php vendor/tesis/db-layer/migrator
```

after running migrator, new database is created tables are created tables are populated

### Example of configuration file

[](#example-of-configuration-file)

```
$config = [
    'dbHost' => 'localhost',
    'dbUser' => 'user',
    'dbPass' => 'pass',
    'dbName' => 'test_db',
    'dbCharset' => 'utf8',
    'mapperDir' => 'mappers',
    'mapperFile' => 'dbTablesMapper',
    'mapperType' => 'json',
    'contactEmail' => 'your_email@dot.com',
    'environment' => 'dev',
    'debug' => true
];
```

### Geneate table mapper

[](#geneate-table-mapper)

run the command bellow and you'll be guided through the process

```
php vendor/tesis/db-layer/generator
```

Documentation / Usage
=====================

[](#documentation--usage)

At the moment, there are examples provided in example dir.

License
=======

[](#license)

MIT License

Last Version
============

[](#last-version)

1.0

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/548acde2f88a80e185f45c18c1213bd2725d45e76b6168ca2019dcd45b1e6147?d=identicon)[tesis](/maintainers/tesis)

---

Top Contributors

[![tesis](https://avatars.githubusercontent.com/u/1144535?v=4)](https://github.com/tesis "tesis (11 commits)")

### Embed Badge

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

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

###  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)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

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

Reliese Components for Laravel Framework code generation.

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

PHPackages © 2026

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