PHPackages                             alex-kalanis/kw\_mapper - 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. alex-kalanis/kw\_mapper

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

alex-kalanis/kw\_mapper
=======================

Mapper for accessing resources in KWCMS

v3.2.0(1y ago)09605BSD-3-ClausePHPPHP &gt;=7.4.0CI passing

Since May 10Pushed 1y ago1 watchersCompare

[ Source](https://github.com/alex-kalanis/kw_mapper)[ Packagist](https://packagist.org/packages/alex-kalanis/kw_mapper)[ RSS](/packages/alex-kalanis-kw-mapper/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (10)Dependencies (8)Versions (23)Used By (5)

kw\_mapper
==========

[](#kw_mapper)

[![Build Status](https://github.com/alex-kalanis/kw_mapper/actions/workflows/code_checks.yml/badge.svg)](https://github.com/alex-kalanis/kw_mapper/actions/workflows/code_checks.yml/badge.svg)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/6019304a3b64599f4744067cac03bdef6f1003a4b20dd14b38b48fbc621dda81/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f616c65782d6b616c616e69732f6b775f6d61707065722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/alex-kalanis/kw_mapper/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/cc67a2e591fb440fea50d7258f12b788415ee9b7116e3972dc30f2d2486fcfa8/68747470733a2f2f706f7365722e707567782e6f72672f616c65782d6b616c616e69732f6b775f6d61707065722f762f737461626c652e7376673f763d31)](https://packagist.org/packages/alex-kalanis/kw_mapper)[![Minimum PHP Version](https://camo.githubusercontent.com/0e9ac047546796cfdbe1423d1f4d91c8f37d2fbb11614a7900bb7686aaa5401f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230372e342d3838393242462e737667)](https://php.net/)[![Downloads](https://camo.githubusercontent.com/eaf852672c69e4bfc8e99299256686bcf9f4865ac8dfd0d12cc2028780cd586b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616c65782d6b616c616e69732f6b775f6d61707065722e7376673f7631)](https://packagist.org/packages/alex-kalanis/kw_mapper)[![License](https://camo.githubusercontent.com/ef0d84f4cf6c13567fcee240015b41221603655d805d366f8b994cd410bd67b1/68747470733a2f2f706f7365722e707567782e6f72672f616c65782d6b616c616e69732f6b775f6d61707065722f6c6963656e73652e7376673f763d31)](https://packagist.org/packages/alex-kalanis/kw_mapper)[![Code Coverage](https://camo.githubusercontent.com/2afaf33b45e1ae7f22513b00f99cfde1725bf6918eb7b7a1b1ed0004bf709282/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f616c65782d6b616c616e69732f6b775f6d61707065722f6261646765732f636f7665726167652e706e673f623d6d617374657226763d31)](https://scrutinizer-ci.com/g/alex-kalanis/kw_mapper/?branch=master)

Mapping records and their entries onto other object like tables or files. You can choose from multiple sources - raw files in local or remote storage, SQL and NoSQL databases.

kw\_mapper is an ORM with separated layers of mappers, records and entries - that allows it to exchange mappers on-the-fly and target it to the different data storages like files or databases. So it's possible to use one record to process data on more storages and yet it will behave nearly the same way.

Basic layer is Record (like line in db) which contains Entries (like each db column with data). The Mapper itself stays outside and tells how to translate data in Record to storage and back.

There is many available storages:

- MySQL/MariaDB (obviously)
- SqLite (for smaller projects with need of sql engine)
- Postgres (for larger projects where My is too problematic)
- MS SQL (for commercial and things like Azure)
- MongoDb (for SQL haters)
- simple table in file
- Csv file
- Ini file
- Yaml file
- Json string
- and with a little tweaking a bit more (Odbc, Dba with their connections, Oracle, Ldap, ...)

It's also possible to limit user with its input on Record level or leave him with limits on storage. But then remember that every storage behaves differently for unwanted input!

### The main differences

[](#the-main-differences)

What is the main differences against its competitors? At first datasources. With competitors you can usually have only one datasource - preset database. This can have more datasources. So usually more connections to databases. You can have main storage in Postgres, yet authentication can run from LDAP and ask for remote data in JSON.

Another one is the files. This mapper was build with files in mind. The file itself behave just like another datasource. Its content can be accessed as raw one or as another table.

With both of these things this mapper is good for transformation of data from one storage to another.

Next one is access to raw queries only per mapper. That makes you comply with each datasource engine separately for your customized queries. So you cannot use the same complicated "join" query for both files and database of different kinds.

Then here is a deep join. So you can use *Search* to access deeper stored records in some datasources and filter by them in built query. No shallow lookups through only relations of current record anymore! But beware that sometimes it's better to ask more times than once in one complicated query!

Another one is in relations. Here is it an array. Always. No additional checks or definitions if that come from 1:1, 1:N or M:N. It's an array. Period. It can be empty, it can contain something. It's more universal than with the definitions like oneToMany. It has been proven that this is the more simple way. In the parent project.

PHP Installation
----------------

[](#php-installation)

```
composer.phar require alex-kalanis/kw_mapper
```

(Refer to [Composer Documentation](https://github.com/composer/composer/blob/master/doc/00-intro.md#introduction) if you are not familiar with composer)

PHP Usage
---------

[](#php-usage)

As usual, setting the storage connections and queries is more complicated than it seems. You need to set connection to the storage and representation of parts there. This is usually the most tedious thing, but it's necessary. Other solutions use discovery, but that is not possible here due need to set things differently and see what it already did. And better debug when something fails due straightforward nature of this code. Little to no magic here.

1.) Use your autoloader (if not already done via Composer autoloader) to allow access to the classes.

2.) Add some external dependencies with connection to the local or remote services. Mainly and usually the database connections and necessary underlying libraries like PDO.

3.) Make representations of each used group. Usually tables. Note that you need to set both Record entity (child of `\kalanis\kw_mapper\Records\ARecord`) and Mapper (child of `\kalanis\kw_mapper\Mappers\AMapper`). Also note that both abstract classes already have some full/abstract children available. So choose best-suited ones and go from there. Not need to make all groups at once, just use the first ones need.

4.) Use Records directly or via `\kalanis\kw_mapper\Search\Search` library to work with data.

If you want to know a bit more, just open `examples/` directory and see the code there. There is a small set of examples what to do and where.

It is also possible to change mappers on Record on-the-fly. That is nice for one of variant of transformation from one storage to another. Another variant is with different sources in Mappers.

Caveats
-------

[](#caveats)

The most of the dialects for database has no limits when updating or deleting - and roundabout way is to get sub-query with dialect-unknown primary column by which the db will limit selection.

Another one is when you define children with the same alias - you cannot ask for them in one query or they will mesh together and you got corrupted data. In better case. For this case there are available children methods which allows you to define alias to pass data when it's necessary to join from already used table. Down it make aliases for specific columns and that allows to separate the result back into Records.

### Possible future things

[](#possible-future-things)

- Accessing the data across the datasources as one big bulk of data. Not like now when the query across the datasources will fail. As expected for now.
- Extending available datasources with its dialects
- Extending processing and coverage over the platform-specific datasources.
- Heavy DI

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance46

Moderate activity, may be stable

Popularity14

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity58

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

Recently: every ~149 days

Total

22

Last Release

417d ago

Major Versions

v0.15.0 → v1.0.02022-09-15

v1.0.1 → v2.0.02023-01-01

v2.5.0 → v3.0.02024-04-01

PHP version history (2 changes)v0.8.0PHP &gt;=7.2.0

v3.0.0PHP &gt;=7.4.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/59184183?v=4)[Petr Plsek](/maintainers/alex-kalanis)[@alex-kalanis](https://github.com/alex-kalanis)

---

Top Contributors

[![alex-kalanis](https://avatars.githubusercontent.com/u/59184183?v=4)](https://github.com/alex-kalanis "alex-kalanis (107 commits)")

---

Tags

databasemysqlsqlitepostgressqlmssqloraclefilefilesmappermongodbldap

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/alex-kalanis-kw-mapper/health.svg)

```
[![Health](https://phpackages.com/badges/alex-kalanis-kw-mapper/health.svg)](https://phpackages.com/packages/alex-kalanis-kw-mapper)
```

###  Alternatives

[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k605.0M6.8k](/packages/doctrine-dbal)[catfan/medoo

The lightweight PHP database framework to accelerate development

5.0k1.6M205](/packages/catfan-medoo)[dg/adminer-custom

Customization for Adminer, the best database management tool written in PHP.

136792.4k16](/packages/dg-adminer-custom)[moharrum/laravel-adminer

Adminer database management tool for your Laravel application.

451.0k](/packages/moharrum-laravel-adminer)

PHPackages © 2026

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