PHPackages                             fyre/typeparser - 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. fyre/typeparser

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

fyre/typeparser
===============

A database type parser library.

v6.0.1(7mo ago)0573↓85.7%16MITPHP

Since Jan 20Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/elusivecodes/FyreTypeParser)[ Packagist](https://packagist.org/packages/fyre/typeparser)[ RSS](/packages/fyre-typeparser/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (10)Dependencies (6)Versions (35)Used By (6)

FyreTypeParser
==============

[](#fyretypeparser)

**FyreTypeParser** is a free, open-source database type parser library for *PHP*.

Table Of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Basic Usage](#basic-usage)
- [Methods](#methods)
- [Types](#types)
    - [Binary](#binary)
    - [Boolean](#boolean)
    - [DateTime](#datetime)
    - [DateTime (Fractional)](#datetime-fractional)
    - [DateTime (Time Zone)](#datetime-time-zone)
    - [Decimal](#decimal)
    - [Enum](#enum)
    - [Float](#float)
    - [Integer](#integer)
    - [Json](#json)
    - [Set](#set)
    - [String](#string)
    - [Text](#text)
    - [Time](#time)

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

[](#installation)

**Using Composer**

```
composer require fyre/typeparser

```

In PHP:

```
use Fyre\DB\TypeParser;
```

Basic Usage
-----------

[](#basic-usage)

- `$container` is a [*Container*](https://github.com/elusivecodes/FyreContainer).

```
$typeParser = new TypeParser($container);
```

**Autoloading**

It is recommended to bind the *TypeParser* to the [*Container*](https://github.com/elusivecodes/FyreContainer) as a singleton.

```
$container->singleton(TypeParser::class);
```

Any dependencies will be injected automatically when loading from the [*Container*](https://github.com/elusivecodes/FyreContainer).

```
$typeParser = $container->use(TypeParser::class);
```

Methods
-------

[](#methods)

**Clear**

Clear all loaded types.

```
$typeParser->clear();
```

**Get Type**

Get the mapped [*Type*](#types) class for a value type.

- `$type` is a string representing the value type.

```
$typeClass = $typeParser->getType($type);
```

**Get Type Map**

Get the type class map.

```
$typeMap = $typeParser->getTypeMap();
```

**Map**

Map a value type to a class.

- `$type` is a string representing the value type.
- `$typeClass` is a string representing the class name.

```
$typeParser->map($type, $typeClass);
```

**Use**

Load a shared [*Type*](#types) instance for a value type.

- `$type` is a string representing the value type.

```
$parser = $typeParser->use($type);
```

Custom [*Type*](#types) dependencies will be resolved automatically from the [*Container*](https://github.com/elusivecodes/FyreContainer).

Types
-----

[](#types)

You can load a specific type parser by specifying the `$type` argument of the `use` method above.

Custom type parsers can be created by extending `\Fyre\DB\Types\Type`, ensuring all below methods are implemented.

**From Database**

Parse a database value to PHP value.

- `$value` is the value to parse.

```
$parsedValue = $parser->fromDatabase($value);
```

**Parse**

Parse a user value to PHP value.

- `$value` is the value to parse.

```
$parsedValue = $parser->parse($value);
```

**To Database**

Parse a PHP value to database value.

- `$value` is the value to parse.

```
$dbValue = $parser->toDatabase($value);
```

### Binary

[](#binary)

```
$parser = $typeParser->use('binary');
```

### Boolean

[](#boolean)

```
$parser = $typeParser->use('boolean');
// or $typeParser->use('bool');
```

### Date

[](#date)

```
$parser = $typeParser->use('date');
```

**Get Locale Format**

Get the locale format.

```
$format = $parser->getLocaleFormat();
```

**Set Locale Format**

Set the locale format.

- `$format` is a string representing the locale format.

```
$parser->setLocaleFormat($format);
```

### DateTime

[](#datetime)

```
$parser = $typeParser->use('datetime');
```

**Get Locale Format**

Get the locale format.

```
$format = $parser->getLocaleFormat();
```

**Get Server Time Zone**

Get the server time zone.

```
$timeZone = $parser->getServerTimeZone();
```

**Get User Time Zone**

Get the user time zone.

```
$timeZone = $parser->getUserTimeZone();
```

**Set Locale Format**

Set the locale format.

- `$format` is a string representing the locale format, or a *Closure* that returns the locale format.

```
$parser->setLocaleFormat($format);
```

**Set Server Time Zone**

Get the server time zone.

- `$timeZone` is a string representing the time zone name.

```
$parser->setServerTimeZone($timeZone);
```

**Set User Time Zone**

Get the user time zone.

- `$timeZone` is a string representing the time zone name, or a *Closure* that returns the time zone name.

```
$parser->setUserTimeZone($timeZone);
```

### DateTime (Fractional)

[](#datetime-fractional)

```
$parser = $typeParser->use('datetime-fractional');
```

**Get Locale Format**

Get the locale format.

```
$format = $parser->getLocaleFormat();
```

**Get Server Time Zone**

Get the server time zone.

```
$timeZone = $parser->getServerTimeZone();
```

**Get User Time Zone**

Get the user time zone.

```
$timeZone = $parser->getUserTimeZone();
```

**Set Locale Format**

Set the locale format.

- `$format` is a string representing the locale format.

```
$parser->setLocaleFormat($format);
```

**Set Server Time Zone**

Get the server time zone.

- `$timeZone` is a string representing the time zone name.

```
$parser->setServerTimeZone($timeZone);
```

**Set User Time Zone**

Get the user time zone.

- `$timeZone` is a string representing the time zone name.

```
$parser->setUserTimeZone($timeZone);
```

### DateTime (Time Zone)

[](#datetime-time-zone)

```
$parser = $typeParser->use('datetime-timezone');
```

**Get Locale Format**

Get the locale format.

```
$format = $parser->getLocaleFormat();
```

**Get Server Time Zone**

Get the server time zone.

```
$timeZone = $parser->getServerTimeZone();
```

**Get User Time Zone**

Get the user time zone.

```
$timeZone = $parser->getUserTimeZone();
```

**Set Locale Format**

Set the locale format.

- `$format` is a string representing the locale format.

```
$parser->setLocaleFormat($format);
```

**Set Server Time Zone**

Get the server time zone.

- `$timeZone` is a string representing the time zone name.

```
$parser->setServerTimeZone($timeZone);
```

**Set User Time Zone**

Get the user time zone.

- `$timeZone` is a string representing the time zone name.

```
$parser->setUserTimeZone($timeZone);
```

### Decimal

[](#decimal)

```
$parser = $typeParser->use('decimal');
```

### Enum

[](#enum)

```
$parser = $typeParser->use('enum');
```

### Float

[](#float)

```
$parser = $typeParser->use('float');
```

### Integer

[](#integer)

```
$parser = $typeParser->use('integer');
// or $typeParser->use('int');
```

### Json

[](#json)

```
$parser = $typeParser->use('json');
```

**Set Encoding Flags**

Set the encoding flags.

- `$flags` is a number representing the encoding flags.

```
$parser->setEncodingFlags($flags);
```

### Set

[](#set)

```
$parser = $typeParser->use('set');
```

### String

[](#string)

```
$parser = $typeParser->use('string');
```

### Text

[](#text)

```
$parser = $typeParser->use('text');
```

### Time

[](#time)

```
$parser = $typeParser->use('time');
```

**Get Locale Format**

Get the locale format.

```
$format = $parser->getLocaleFormat();
```

**Set Locale Format**

Set the locale format.

- `$format` is a string representing the locale format.

```
$parser->setLocaleFormat($format);
```

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance62

Regular maintenance activity

Popularity14

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity61

Established project with proven stability

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

Recently: every ~30 days

Total

34

Last Release

233d ago

Major Versions

v1.0.4 → v2.02023-07-18

v2.0.3 → v3.02024-06-02

v3.2.1 → v4.02024-10-28

v4.0.2 → v5.02024-11-02

v5.1.5 → v6.02025-10-25

### Community

Maintainers

![](https://www.gravatar.com/avatar/fad81fd5941e3a637c8a5749d05ae3ed9314d5e2fee57f59c3d9ec3b41259c6b?d=identicon)[elusivecodes](/maintainers/elusivecodes)

---

Top Contributors

[![elusivecodes](https://avatars.githubusercontent.com/u/18050480?v=4)](https://github.com/elusivecodes "elusivecodes (32 commits)")

---

Tags

databasephptype-parser

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/fyre-typeparser/health.svg)

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

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k116.5M113](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)

PHPackages © 2026

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