Statistics
987
1
0
64d
Badges
Dependencies

Entity generator

Typed entity generator from database. It can generate entities for whole database, table/view and from query


Latest Stable Version Build Status codecov PHPStan Total Downloads License

Installation

$ composer require dodo-it/entity-generator

USAGE:

$config = new \DodoIt\EntityGenerator\Generator\Config([
    'path' =>  __DIR__ . '/Entities',
    'extends' => \Examples\Pdo\Entities\Entity::class,
    'namespace' => 'Examples\Pdo\Entities'
]);

$pdo = new \PDO('mysql:dbname=example;host=127.0.0.1', 'root', '');

$generatorFactory = new \DodoIt\EntityGenerator\Factory\GeneratorPdoFactory($pdo);
$generator = $generatorFactory->create($config);
$generator->generate();

see example folder

You can add your own methods to entities and change getter/setter functions, they won't be overriden when regenerated

Configuration

see src/Generator/Config.php

  • 1.0.9 1.0.9

    • fix regenerating mapping
    • fix regenerating constants
    • add more unit tests
  • 1.0.8 1.0.8

    • constants are allways regenerated becase phpgenerator <=2.6.* does not have info on constants
    • mapping is now being merged so it doesn't skip mappings from previous version of entity
  • 1.0.7 1.0.7

    • support for !rewrite with phpdoc properties
  • 1.0.6 1.0.6

    • by default use \DateTimeInterface for datetime instead of \DateTime
    • option to generate column constant
    • better replacements per word
  • 1.0.5

    • option to rewrite config (generate new entity and overwrite all existing files)
    • add mapping (array where key is table column name and value is entity name)
    • allow setting getters/setters body
    • make sure column constant name is not class (add _ before if it is)
  • 1.0.4 1.0.4

    • bugfix: use table constant name from table
  • 1.0.3 1.0.3

    • singularize all words not just last one
    • allow setting visibility on getters and setters
  • 1.0.2 1.0.2

    • feature: option to generate phpdoc properties
    • bugfix: skip generating properties if generateProperties = false
  • 1.0.1 1.0.1

    • support for generating column constant
    • setup travis build and add badges to readme
  • 1.0.0 1.0.0

Is this addon outdated? Did you find an issue? Please report it.

Componette Componette admin@componette.com