PHPackages                             nlzet/doctrine-mapping-typings - 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. nlzet/doctrine-mapping-typings

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

nlzet/doctrine-mapping-typings
==============================

convert doctrine entities into typescript typings

0.2.1(1y ago)0746↓20%[1 PRs](https://github.com/nlzet/doctrine-mapping-typings/pulls)1MITPHPPHP &gt;=8.1CI passing

Since Sep 30Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/nlzet/doctrine-mapping-typings)[ Packagist](https://packagist.org/packages/nlzet/doctrine-mapping-typings)[ Docs](https://github.com/nlzet/NlzetDoctrineMappingTypings)[ RSS](/packages/nlzet-doctrine-mapping-typings/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (16)Versions (5)Used By (1)

Doctrine mapping typings generator
==================================

[](#doctrine-mapping-typings-generator)

About
-----

[](#about)

This is a library to create typescript typings based on your doctrine mapping.

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

[](#installation)

Install with composer:

```
composer require nlzet/doctrine-mapping-typings
```

Configuration
-------------

[](#configuration)

```
// Exclude patterns: Add regex or string patterns of FQCNs to exclude from the typings (don't add \ in the search patterns).
$generatorConfig->setExcludePatterns(['/P[ea]rson/', 'Keyword']);
// Class aliases: Add class aliases to replace the original class name with a custom name. Class aliases take precedence over class replacements.
$generatorConfig->setClassAliases(['NlzetDoctrineMappingTypingsTestsFixtureEntityAddress' => 'NlzetCustomAddress']);
// Class replacements: Add class replacements key-value pairs to replace the original class name with a custom name.
$generatorConfig->setClassReplacements(['NlzetDoctrineMappingTypingsTestsFixtureEntity' => 'Nlzet']);
// Only exposed: Set to true to only generate typings for exposed properties, defined by JMS Serializer Expose/Exclude and ExclusionPolicy.
$generatorConfig->setOnlyExposed(true);
// Only exposed: Set to true to always set properties as optional.
$generatorConfig->setAlwaysOptional(true);
// Only exposed: Set to true to treat nullable properties as optional type properties.
$generatorConfig->setTreatNullableAsOptional(true);
```

Example
-------

[](#example)

See the [example](example/) directory for a full example, using [these example entities](tests/Fixture/Entity/). Run the example yourself with `php example/basic.php`

### Input code

[](#input-code)

```
use Doctrine\ORM\EntityManager;
use Nlzet\DoctrineMappingTypings\Doctrine\EntityReader;
use Nlzet\DoctrineMappingTypings\Typings\GeneratorConfig;
use Nlzet\DoctrineMappingTypings\Typings\ModelTypingGenerator;

$generatorConfig = new GeneratorConfig();
$generatorConfig->setExcludePatterns([]);
$generatorConfig->setOnlyExposed(false);
$generatorConfig->setTreatOptionalAsNullable(false);
$generatorConfig->setTreatNullableAsOptional(false);
$generatorConfig->setClassAliases(['NlzetDoctrineMappingTypingsTestsFixtureEntityAddress' => 'NlzetCustomAddress']);
$generatorConfig->setClassReplacements(['NlzetDoctrineMappingTypingsTestsFixtureEntity' => 'Nlzet']);
$reader = new EntityReader($generatorConfig, $entityManager);

$generator = new ModelTypingGenerator($generatorConfig);
foreach ($reader->getEntities() as $classMeta) {
    $outputs[] = $generator->generate($classMeta, $reader->getProperties($classMeta->getName()));
}

echo implode(\PHP_EOL, $outputs).\PHP_EOL;
```

### Output example

[](#output-example)

```
export type NlzetCustomAddress = {
    id: number;
    houseNumber?: string;
    city: string;
    zip: string;
    country?: string;
    floor?: number;
    latitude?: number;
    longitude?: number;
    isPrivate: boolean;
    createdAt: any;
    updatedAt: any;
    createdDate: number;
};

export type NlzetExamplePropertyTypes = {
    id: number;
    stringDefault: string;
    stringNullable?: string;
    integerDefault: number;
    integerNullable?: number;
    floatDefault: number;
    floatNullable?: number;
    decimalDefault: number;
    decimalNullable?: number;
    booleanDefault: boolean;
    booleanNullable?: boolean;
    datetimeDefault: any;
    datetimeNullable: any;
    timestampDefault: number;
    timestampNullable?: number;
    arrayDefault: any[];
    arrayNullable?: any[];
    simpleArrayDefault: any[];
    simpleArrayNullable?: any[];
    jsonDefault: any[];
    jsonNullable?: any[];
    objectDefault: any;
    objectNullable: any;
    blobDefault: any;
    blobNullable: any;
    guidDefault: string;
    guidNullable?: string;
    dateDefault: any;
    dateNullable: any;
    timeDefault: number;
    timeNullable?: number;
    datetimeImmutableDefault: any;
    datetimeImmutableNullable: any;
    timestampImmutableDefault: number;
    timestampImmutableNullable?: number;
    dateImmutableDefault: any;
    dateImmutableNullable: any;
    timeImmutableDefault: number;
    timeImmutableNullable?: number;
};

export type NlzetPerson = {
    id: number;
    name: string;
    extraData: any[];
    createdAt: any;
    updatedAt: any;
    createdDate: number;
    addresses: NlzetCustomAddress[];
};
```

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance55

Moderate activity, may be stable

Popularity18

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.7% 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 ~9 days

Total

3

Last Release

571d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/394ba4724b1dea1531cf482420137461004ae839030048c178b5a18b336bd961?d=identicon)[nlzet](/maintainers/nlzet)

---

Top Contributors

[![niels3W](https://avatars.githubusercontent.com/u/13118004?v=4)](https://github.com/niels3W "niels3W (2 commits)")[![nlzet](https://avatars.githubusercontent.com/u/932439?v=4)](https://github.com/nlzet "nlzet (1 commits)")

---

Tags

converterdoctrinedoctrine2entitiesentitymappingmetadatamodelstypescripttypingsclisymfonydoctrinetypescript

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/nlzet-doctrine-mapping-typings/health.svg)

```
[![Health](https://phpackages.com/badges/nlzet-doctrine-mapping-typings/health.svg)](https://phpackages.com/packages/nlzet-doctrine-mapping-typings)
```

###  Alternatives

[fresh/doctrine-enum-bundle

Provides support of ENUM type for Doctrine2 in Symfony applications.

4636.8M12](/packages/fresh-doctrine-enum-bundle)[scienta/doctrine-json-functions

A set of extensions to Doctrine that add support for json query functions.

58523.9M36](/packages/scienta-doctrine-json-functions)[sonata-project/doctrine-orm-admin-bundle

Integrate Doctrine ORM into the SonataAdminBundle

46117.7M155](/packages/sonata-project-doctrine-orm-admin-bundle)[damienharper/auditor-bundle

Integrate auditor library in your Symfony projects.

4542.8M](/packages/damienharper-auditor-bundle)[doctrineencryptbundle/doctrine-encrypt-bundle

Encrypted symfony entity's by verified and standardized libraries

29415.1k](/packages/doctrineencryptbundle-doctrine-encrypt-bundle)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1022.4k](/packages/rcsofttech-audit-trail-bundle)

PHPackages © 2026

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