Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
dakorpar authored Feb 23, 2019
1 parent 4d4b59b commit 60df333
Showing 1 changed file with 10 additions and 147 deletions.
157 changes: 10 additions & 147 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@ Typed entity generator from database. It can generate entities for whole databas
$ composer require dodo-it/entity-generator

## USAGE:
$config = [
'path' => __DIR__ . '/Entities',
'extends' => \Examples\Pdo\Entities\Entity::class,
'namespace' => 'Examples\Pdo\Entities'
];
$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', '');

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

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



Expand All @@ -28,141 +27,5 @@ You can add your own methods to entities and change getter/setter functions, the


## Configuration
this are defaults

$config = [
'path' => NULL
'namespace' => 'App\\Models\Entities',
'typeMapping' => [
'int' => ['int', 'bigint', 'mediumint', 'smallint' ],
'float' => ['decimal', 'float'],
'bool' => ['bit', 'tinyint'],
'\DateTime' => ['date', 'datetime', 'timestamp'],
'\DateInterval' => ['time']
],
'replacements' => [],
'prefix' => '',
'suffix' => 'Entity',
'extends' => \Examples\Pdo\Entity::class,
'gettersAndSetters' => true,
'propertyVisibility' => 'protected'
];
# Example of generated entity:

<?php
namespace Examples\Pdo\Entities;

class ArticleEntity extends Entity
{
public const TABLE = 'articles';

/**
* @var int
*/
protected $id;

/**
* @var int
*/
protected $category_id;

/**
* @var string
*/
protected $title;

/**
* @var string
*/
protected $content;

/**
* @var bool
*/
protected $published;

/**
* @var \DateTime
*/
protected $created_at;


public function getId(): int
{
return $this->id;
}


public function setId(int $value): self
{
$this['id'] = $value;
return $this;
}


public function getCategoryId(): int
{
return $this->category_id;
}


public function setCategoryId(int $value): self
{
$this['category_id'] = $value;
return $this;
}


public function getTitle(): ?string
{
return $this->title;
}


public function setTitle(?string $value): self
{
$this['title'] = $value;
return $this;
}


public function getContent(): ?string
{
return $this->content;
}


public function setContent(?string $value): self
{
$this['content'] = $value;
return $this;
}


public function getPublished(): bool
{
return $this->published;
}


public function setPublished(bool $value): self
{
$this['published'] = $value;
return $this;
}


public function getCreatedAt(): ?\DateTime
{
return $this->created_at;
}


public function setCreatedAt(?\DateTime $value): self
{
$this['created_at'] = $value;
return $this;
}
}
see src/Generator/Config.php

0 comments on commit 60df333

Please sign in to comment.