PHPackages                             toutaphp/ogam-data-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. toutaphp/ogam-data-mapper

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

toutaphp/ogam-data-mapper
=========================

A MyBatis-inspired SQL mapping framework for PHP. Write the SQL you want, map results to objects automatically.

v0.2.0(5mo ago)00MITPHPPHP &gt;=8.3CI passing

Since Jan 20Pushed 5mo agoCompare

[ Source](https://github.com/toutaio/toutaphp-ogam-data-mapper)[ Packagist](https://packagist.org/packages/toutaphp/ogam-data-mapper)[ Docs](https://github.com/toutaio/toutaphp-ogam-data-mapper)[ RSS](/packages/toutaphp-ogam-data-mapper/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (6)Versions (8)Used By (0)

Touta Ogam - Data Mapper for PHP
================================

[](#touta-ogam---data-mapper-for-php)

[![CI](https://github.com/toutaio/toutaphp-ogam-data-mapper/actions/workflows/ci.yml/badge.svg)](https://github.com/toutaio/toutaphp-ogam-data-mapper/actions/workflows/ci.yml)[![PHP Version](https://camo.githubusercontent.com/7e80c5a44b0f819258f09384c7af693fe7f3f1ebe4ae8c6833b5c34f2dd57d03/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e332d3838393242462e737667)](https://php.net/)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)

**Ogam** (ᚑᚌᚐᚋ) is a MyBatis-inspired SQL mapping framework for PHP. Write the SQL you want, map results to objects automatically.

> **Ogam** is the ancient Celtic alphabet used by Druids to inscribe sacred knowledge. Like Ogam mapped symbols to meaning, this library maps SQL results to PHP objects.

Features
--------

[](#features)

- **SQL-First**: Write exactly the SQL you want, optimized for your use case
- **Declarative Mapping**: Configure how results become objects via XML or attributes
- **Dynamic SQL**: Build queries conditionally with ``, ``, ``, ``
- **Type Handlers**: Automatic conversion between PHP and SQL types (DateTime, Enums, JSON)
- **Zero Magic**: Every SQL executed is visible and predictable
- **Framework Agnostic**: Works standalone or with Symfony/Laravel

Requirements
------------

[](#requirements)

- PHP 8.3+
- PDO extension
- MySQL, PostgreSQL, or SQLite

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

[](#installation)

```
composer require toutaphp/ogam-data-mapper
```

Quick Start
-----------

[](#quick-start)

### 1. Define Your Entity

[](#1-define-your-entity)

```

```

### 3. Create XML Mapper

[](#3-create-xml-mapper)

```

        SELECT id, name, email, email_verified_at, password, remember_token, created_at, updated_at
        FROM users
        WHERE id = #{id}

        SELECT id, name, email, email_verified_at, password, remember_token, created_at, updated_at
        FROM users

                AND status = #{status}

        INSERT INTO users (name, email, email_verified_at, password, remember_token, created_at, updated_at)
        VALUES (#{name}, #{email}, #{emailVerifiedAt}, #{password}, #{rememberToken}, #{createdAt}, #{updatedAt})

```

### 4. Define Mapper Interface

[](#4-define-mapper-interface)

```
