{"id":15026727,"url":"https://github.com/dodo-it/entity-generator","last_synced_at":"2025-07-29T23:04:28.396Z","repository":{"id":34047435,"uuid":"172254164","full_name":"dodo-it/entity-generator","owner":"dodo-it","description":"Highly customizable (typed) entity generator from database. It can generate entities for whole database, table/view and from raw SQL query","archived":false,"fork":false,"pushed_at":"2025-02-17T09:19:45.000Z","size":112,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-14T09:26:47.014Z","etag":null,"topics":["database","entities","generator","php74"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dodo-it.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-23T19:21:17.000Z","updated_at":"2025-02-17T09:17:57.000Z","dependencies_parsed_at":"2024-09-28T20:01:26.161Z","dependency_job_id":"011bb2e2-060e-4137-bd76-41841242a84f","html_url":"https://github.com/dodo-it/entity-generator","commit_stats":{"total_commits":74,"total_committers":1,"mean_commits":74.0,"dds":0.0,"last_synced_commit":"ca8959d95f903041e53eb24b12aa9a2be69aff03"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/dodo-it/entity-generator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dodo-it%2Fentity-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dodo-it%2Fentity-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dodo-it%2Fentity-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dodo-it%2Fentity-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dodo-it","download_url":"https://codeload.github.com/dodo-it/entity-generator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dodo-it%2Fentity-generator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267777477,"owners_count":24142820,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","entities","generator","php74"],"created_at":"2024-09-24T20:04:58.705Z","updated_at":"2025-07-29T23:04:28.369Z","avatar_url":"https://github.com/dodo-it.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n## Entity generator\nHighly customizable (typed) entity generator from database. It can generate entities for whole database, table/view and from raw SQL query\n\n-----\n[![Latest Stable Version](https://poser.pugx.org/dodo-it/entity-generator/v/stable)](https://packagist.org/packages/dodo-it/entity-generator)\n[![build](https://github.com/dodo-it/entity-generator/workflows/build/badge.svg)](https://github.com/dodo-it/entity-generator/actions?query=workflow%3Abuild)\n[![Coverage Status](https://coveralls.io/repos/github/dodo-it/entity-generator/badge.svg?branch=master)](https://coveralls.io/github/dodo-it/entity-generator?branch=master)\n[![PHPStan](https://img.shields.io/badge/PHPStan-enabled-brightgreen.svg?style=flat)](https://github.com/phpstan/phpstan)\n[![Total Downloads](https://poser.pugx.org/dodo-it/entity-generator/downloads)](https://packagist.org/packages/dodo-it/entity-generator)\n[![License](https://poser.pugx.org/dodo-it/entity-generator/license)](https://packagist.org/packages/dodo-it/entity-generator)\n\n## Installation\n\n    $ composer require dodo-it/entity-generator\n\n## How to run:\n ```php\n    $config = new \\DodoIt\\EntityGenerator\\Generator\\Config([\n        'path' =\u003e  __DIR__ . '/Entities',\n        'extends' =\u003e \\Examples\\Pdo\\Entities\\Entity::class,\n        'namespace' =\u003e 'Examples\\Pdo\\Entities'\n    ]);\n\n    $pdo = new \\PDO('mysql:dbname=example;host=127.0.0.1', 'root', '');\n\n    $generatorFactory = new \\DodoIt\\EntityGenerator\\Factory\\GeneratorPdoFactory($pdo);\n    $generator = $generatorFactory-\u003ecreate($config);\n    $generator-\u003egenerate();\n ```\n\n## What kind of entities can I get?\nTool is highly customizable and can generate various different entity types of which most interesting are:\n\n - PHP 7.4 typed properties\n ```php\nclass ArticleEntity extends YourBaseEntity\n{\n\tpublic int $id;\n\n\tpublic ?string $title;\n\n\tpublic bool $published;\n\n\tpublic ?\\DateTimeInterface $created_at;\n}\n```\n - properties with phpdoc\n```php\nclass ArticleEntity extends YourBaseEntity\n{\n\n\t/** @var int */\n\tprotected $id;\n\n\t/** @var string */\n\tprotected $title;\n\n\t/** @var bool */\n\tprotected $published;\n\n\t/** @var \\DateTimeInterface */\n\tprotected $created_at;\n}\n```\n\n- properties with getters and setters (methods body is customizable)\n\n```php\nclass ArticleEntity extends YourBaseEntity\n{\n\n\tpublic function getId(): int\n\t{\n\t\treturn $this-\u003eid;\n\t}\n\n\n\tpublic function setId(int $value): self\n\t{\n\t\t$this['id'] = $value;\n\t\treturn $this;\n\t}\n\n\n\tpublic function getTitle(): ?string\n\t{\n\t\treturn $this-\u003etitle;\n\t}\n\n\n\tpublic function setTitle(?string $value): self\n\t{\n\t\t$this['title'] = $value;\n\t\treturn $this;\n\t}\n\n\n\tpublic function getPublished(): bool\n\t{\n\t\treturn $this-\u003epublished;\n\t}\n\n\n\tpublic function setPublished(bool $value): self\n\t{\n\t\t$this['published'] = $value;\n\t\treturn $this;\n\t}\n\n\n\tpublic function getCreatedAt(): ?\\DateTimeInterface\n\t{\n\t\treturn $this-\u003ecreated_at;\n\t}\n\n\n\tpublic function setCreatedAt(?\\DateTimeInterface $value): self\n\t{\n\t\t$this['created_at'] = $value;\n\t\treturn $this;\n\t}\n```\n\n-  phpdoc properties\n\n```php\n/**\n * @property int $id\n * @property string $title\n * @property int $published\n * @property \\DateTimeInterface $created_at\n */\nclass ArticleEntity extends YourBaseEntity\n{\n}\n```\n\n- properties with phpdoc\n```php\nclass ArticleEntity extends YourBaseEntity\n{\n\t/** @var int */\n\tpublic $id;\n\n\t/** @var string */\n\tpublic $title;\n\n\t/** @var bool */\n\tpublic $published;\n\n\t/** @var \\DateTimeInterface */\n\tpublic $created_at;\n\n```\n\n- it can generate column constants (use generateColumnConstants option)\n\n```php\nclass ArticleEntity extends YourBaseEntity\n{\n    \tpublic const TABLE_NAME = 'articles';\n    \tpublic const ID = 'id';\n    \tpublic const TITLE = 'title';\n    \tpublic const PUBLISHED = 'published';\n    \tpublic const CREATED_AT = 'created_at';\n\n.\n.\n.\n\n```\n- almost any combination you can imagine, check src/Generator/Config.php for list of all options\nsee example folder\n\n\nYou can add your own methods to entities and change getter/setter functions, they won't be overriden when regenerated if rewrite flag is set to false\n\n\n## Configuration\n\nsee src/Generator/Config.php\n\n# Docker integration\n\n## Entity Generator image\n\n![Docker Pulls](https://img.shields.io/docker/pulls/pifou25/entity-generator)\n https://hub.docker.com/r/pifou25/entity-generator\n\n## Generation from existing database\nThe database should be accessible from the docker network, the hostname is either\nthe name of the Mysql running container, or `localhost` if db is running on host.\nThe below command will generate entities into `./entities` directory.\n\n```\ndocker run --rm -v $PWD/entities:/app/entities --network some-network \\\n   -e MYSQL_HOSTNAME=some-mariadb \\\n   -e MYSQL_DATABASE=exmple-database \\\n   -e MYSQL_USERNAME=example-user \\\n   -e MYSQL_PASSWORD=my_cool_secret \\\n    pifou25/entity-generator\n```\n\n## namespace and extends example\nThe base class must exist into /entities to be declared\n```\ndocker run --rm -v $PWD/include/entities:/app/entities --network scripts_default \\\n   -e MYSQL_HOSTNAME=myhost \\\n   -e MYSQL_DATABASE=mydb \\\n   -e MYSQL_USERNAME=myuser \\\n   -e MYSQL_PASSWORD=mypwd \\\n   -e ENTITY_NAMESPACE=Example\\\\Pdo\\\\Entities \\\n   -e BASECLASS=Example\\\\Pdo\\\\Entities\\Entity \\\n    entity-generator\n```\n\n## Generation from flat plain SQL file\n\nThe `docker compose` file create a new database and initialize it with SQL data,\nyou have to put SQL init file into `./examples` directory. When db is ready, \n the entity-generator start on it to generate PHP entities.\n\nIt is as simple as running this command from the `docker` directory :\n`docker compose up`\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdodo-it%2Fentity-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdodo-it%2Fentity-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdodo-it%2Fentity-generator/lists"}