PHPackages                             siburuxue/doctrine-helper - 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. siburuxue/doctrine-helper

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

siburuxue/doctrine-helper
=========================

instead of `php bin/console doctrine:mapping:import`

v1.0.7(1y ago)367.1k↑668.2%7[1 issues](https://github.com/siburuxue/doctrine-helper/issues)Apache-2.0PHPPHP &gt;=8.2

Since Apr 11Pushed 1y ago1 watchersCompare

[ Source](https://github.com/siburuxue/doctrine-helper)[ Packagist](https://packagist.org/packages/siburuxue/doctrine-helper)[ RSS](/packages/siburuxue-doctrine-helper/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (8)Dependencies (5)Versions (12)Used By (0)

[![](./title-white.png)](./title-white.png)

English | [Chinese](README_zh.md)

This tool provides an alternative to the `php bin/console doctrine:mapping:import App\\Entity attribute --path=src/Entity` command in Symfony 7, as the `doctrine:mapping:import` command has been removed in the latest versions. It allows for importing entity mappings from existing databases into Symfony applications.

Supported Databases
-------------------

[](#supported-databases)

- MySQL
- PostgreSQL
- SQLServer
- Oracle
- Sqlite3

Supported Field Types
---------------------

[](#supported-field-types)

### MySQL

[](#mysql)

- Does not support `bit` types
- When supporting `enum` types, you need to set [mapping\_types](https://symfony.com/doc/current/doctrine/dbal.html#registering-custom-mapping-types-in-the-schematool)
- Converts similar types (e.g., `double` to `float`)

### PostgreSQL

[](#postgresql)

- Supports numeric, string, date, currency, JSON, UUID, binary, and boolean types
- Does not support complex or custom types

### SQLServer

[](#sqlserver)

- Supports exact numeric, approximate numeric, date/time, string (char, varchar), Unicode string (nchar, nvarchar), binary string (binary, varbinary), and other data types
- Does not support deprecated or complex data types

### Oracle

[](#oracle)

- Supports various data types such as NUMBER, FLOAT, CHAR, VARCHAR2, DATE, TIMESTAMP, RAW, CLOB, BLOB, etc.
- Does not support other data types

### Sqlite

[](#sqlite)

- Supports integer, real, float, double, decimal, varchar, blob, text, date, datetime, and boolean types

Install
-------

[](#install)

```
composer require siburuxue/doctrine-helper
```

Synchronize database tables to the project
------------------------------------------

[](#synchronize-database-tables-to-the-project)

```
php bin/console doctrine-helper:mapping:import App\\Entity attribute --path=src/Entity --ucfirst=true --table=dict,log --without-table-prefix=eq_
php bin/console doctrine-helper:mapping:import --ucfirst=true
```

Command Line Options
--------------------

[](#command-line-options)

- `namespace`: The namespace for the Entity class (default: `App\Entity`)
- `type`: Type of database field description (attribute, xml, yaml, php) (default: `attribute`, currently only support `attribute`)
- `--path`: Path to store Entity class files (default: `src/Entity`)
- `--ucfirst=true`: Generate Symfony 6 style Entities (private properties in camelCase) for seamless code migration (default: Symfony 7 style with underscored private properties)
- `--table`: Import specific tables to generate corresponding Entity and Repository classes
- `--without-table-prefix`: Ignore table prefix when generating Entities
- `--schema`: when connecting to a postgresql database, synchronize the tables of the specified schema (postgresql only)

In this article, we'll use MySQL as an example to demonstrate the generation result.

Assuming your database contains a table called "test," which includes almost all MySQL data types and has unique indexes, composite indexes, and regular indexes:

```
create table test
(
    id     int                                     not null,
    int_1  int                 default 1           not null comment 'int',
    int_2  smallint            default 2           null comment 'smallint',
    int_3  int                 default 3           null comment 'tinyint',
    int_4  mediumint           default 4           null comment 'mediumint',
    int_5  bigint                                  not null comment 'bigint'
        primary key,
    int_6  double              default 6           null comment 'float',
    int_7  double              default 7           null comment 'double',
    int_8  decimal             default 8           null comment 'decimal',
    date_1 date                default (curdate()) null comment 'date',
    date_2 time                default (curtime()) null comment 'time',
    date_3 datetime            default (now())     null comment 'datetime',
    date_4 timestamp           default (now())     null comment 'timestamp',
    date_5 year                default (now())     null comment 'year',
    str_1  char                default 'a'         null comment 'char',
    str_2  varchar(255)        default 'b'         null comment 'varchar(255)',
    str_3  varbinary(1)        default 0x63        null comment 'binary',
    str_4  varbinary(1)        default 0x64        null comment 'varbinary(1)',
    str_8  set ('a', 'b', 'c') default 'a,b'       null comment 'set',
    json_1 json                                    null comment 'json',
    bool_1 int                 default 0           null comment 'bool',
    constraint I_int_2
        unique (int_2) comment '唯一索引'
)
    comment '测试表';

create index I_int_1
    on test (int_1)
    comment '普通索引';

create index I_int_3
    on test (int_3, int_4, int_5)
    comment '联合索引';

create index I_int_4
    on test (int_6);
```

To generate the corresponding Entity and Repository class files using the command:

```
php bin/console doctrine-helper:mapping:import --ucfirst=true --table=test
```

The newly created Test entity class will look like this:

```
// src/Entity/Test.php
namespace App\Entity;

use App\Repository\TestRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Table(name: 'test')]
#[ORM\UniqueConstraint(name: 'I_int_2', columns: ['int_2'])]
#[ORM\Index(name: 'I_int_1', columns: ['int_1'])]
#[ORM\Index(name: 'I_int_3', columns: ['int_3', 'int_4', 'int_5'])]
#[ORM\Index(name: 'I_int_4', columns: ['int_6'])]
#[ORM\Entity(repositoryClass: TestRepository::class)]
class Test
{
    #[ORM\Column(name: "int_5", type: Types::BIGINT, options: ["comment" => "bigint"])]
    #[ORM\Id]
    #[ORM\GeneratedValue(strategy: "NONE")]
    private ?string $int5 = null;

    #[ORM\Column(name: "id")]
    private ?int $id = null;

    #[ORM\Column(name: "int_1", options: ["comment" => "int", "default" => 1])]
    private ?int $int1 = 1;

    #[ORM\Column(name: "int_2", type: Types::SMALLINT, nullable: true, options: ["comment" => "smallint", "default" => 2])]
    private ?int $int2 = 2;

    #[ORM\Column(name: "int_3", nullable: true, options: ["comment" => "tinyint", "default" => 3])]
    private ?int $int3 = 3;

    #[ORM\Column(name: "int_4", nullable: true, options: ["comment" => "mediumint", "default" => 4])]
    private ?int $int4 = 4;

    #[ORM\Column(name: "int_6", nullable: true, options: ["comment" => "float", "default" => 6])]
    private ?float $int6 = 6;

    #[ORM\Column(name: "int_7", nullable: true, options: ["comment" => "double", "default" => 7])]
    private ?float $int7 = 7;

    #[ORM\Column(name: "int_8", type: Types::DECIMAL, precision: 10, scale: 0, nullable: true, options: ["comment" => "decimal", "default" => 8])]
    private ?string $int8 = '8';

    #[ORM\Column(name: "date_1", type: Types::DATE_MUTABLE, nullable: true, options: ["comment" => "date", "default" => 'curdate()'])]
    private ?\DateTimeInterface $date1 = null;

    #[ORM\Column(name: "date_2", type: Types::TIME_MUTABLE, nullable: true, options: ["comment" => "time", "default" => 'curtime()'])]
    private ?\DateTimeInterface $date2 = null;

    #[ORM\Column(name: "date_3", type: Types::DATETIME_MUTABLE, nullable: true, options: ["comment" => "datetime", "default" => 'now()'])]
    private ?\DateTimeInterface $date3 = null;

    #[ORM\Column(name: "date_4", type: Types::DATETIME_MUTABLE, nullable: true, options: ["comment" => "timestamp", "default" => 'now()'])]
    private ?\DateTimeInterface $date4 = null;

    #[ORM\Column(name: "date_5", type: Types::DATETIME_MUTABLE, nullable: true, options: ["comment" => "year", "default" => 'now()'])]
    private ?\DateTimeInterface $date5 = null;

    #[ORM\Column(name: "str_1", length: 1, nullable: true, options: ["comment" => "char", "fixed" => true, "default" => 'a'])]
    private ?string $str1 = 'a';

    #[ORM\Column(name: "str_2", length: 255, nullable: true, options: ["comment" => "varchar(255)", "default" => 'b'])]
    private ?string $str2 = 'b';

    #[ORM\Column(name: "str_3", type: Types::BINARY, length: 1, nullable: true, options: ["comment" => "binary", "default" => '0x63'])]
    private $str3 = 0x63;

    #[ORM\Column(name: "str_4", type: Types::BINARY, length: 1, nullable: true, options: ["comment" => "varbinary(1)", "default" => '0x64'])]
    private $str4 = 0x64;

    #[ORM\Column(name: "str_8", type: Types::SIMPLE_ARRAY, nullable: true, options: ["comment" => "set", "default" => 'a,b'])]
    private ?array $str8 = ["a","b"];

    #[ORM\Column(name: "json_1", nullable: true, options: ["comment" => "json"])]
    private ?array $json1 = null;

    #[ORM\Column(name: "bool_1", nullable: true, options: ["comment" => "bool", "default" => 0])]
    private ?int $bool1 = 0;

    // ...getter and setter
}
```

Feel free to explore and utilize this tool for managing Doctrine mappings in your Symfony applications!

Contact Us(QQ)
--------------

[](#contact-usqq)

[![](./QQ.jpg)](./QQ.jpg)

###  Health Score

42

—

FairBetter than 89% of packages

Maintenance44

Moderate activity, may be stable

Popularity36

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 88.6% 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 ~73 days

Total

8

Last Release

437d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7badb2786f4084d248bf806669ad60ac36c8fdc796431420d973e15742c8fc76?d=identicon)[siburuxue](/maintainers/siburuxue)

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

---

Top Contributors

[![siburuxue](https://avatars.githubusercontent.com/u/15135780?v=4)](https://github.com/siburuxue "siburuxue (70 commits)")[![CJayHe](https://avatars.githubusercontent.com/u/22066314?v=4)](https://github.com/CJayHe "CJayHe (6 commits)")[![guillaume-sainthillier](https://avatars.githubusercontent.com/u/5052984?v=4)](https://github.com/guillaume-sainthillier "guillaume-sainthillier (2 commits)")[![HugoDelvalL214](https://avatars.githubusercontent.com/u/114984210?v=4)](https://github.com/HugoDelvalL214 "HugoDelvalL214 (1 commits)")

---

Tags

databasedoctrinedoctrine-helpercreate entity from the existing database.

### Embed Badge

![Health badge](/badges/siburuxue-doctrine-helper/health.svg)

```
[![Health](https://phpackages.com/badges/siburuxue-doctrine-helper/health.svg)](https://phpackages.com/packages/siburuxue-doctrine-helper)
```

###  Alternatives

[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M196](/packages/sulu-sulu)[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.

1155.2k](/packages/rcsofttech-audit-trail-bundle)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.4M519](/packages/shopware-core)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1615.6k12](/packages/2lenet-crudit-bundle)[chameleon-system/chameleon-base

The Chameleon System core.

1027.9k4](/packages/chameleon-system-chameleon-base)[bartlett/php-compatinfo-db

Reference Database of all functions, constants, classes, interfaces on PHP standard distribution and about 110 extensions

1184.5k2](/packages/bartlett-php-compatinfo-db)

PHPackages © 2026

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