1. Go to this page and download the library: Download dodo-it/entity-generator library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
dodo-it / entity-generator example snippets
$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();
class ArticleEntity extends YourBaseEntity
{
public int $id;
public ?string $title;
public bool $published;
public ?\DateTimeInterface $created_at;
}
class ArticleEntity extends YourBaseEntity
{
public function getId(): int
{
return $this->id;
}
public function setId(int $value): self
{
$this['id'] = $value;
return $this;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(?string $value): self
{
$this['title'] = $value;
return $this;
}
public function getPublished(): bool
{
return $this->published;
}
public function setPublished(bool $value): self
{
$this['published'] = $value;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->created_at;
}
public function setCreatedAt(?\DateTimeInterface $value): self
{
$this['created_at'] = $value;
return $this;
}
/**
* @property int $id
* @property string $title
* @property int $published
* @property \DateTimeInterface $created_at
*/
class ArticleEntity extends YourBaseEntity
{
}
class ArticleEntity extends YourBaseEntity
{
/** @var int */
public $id;
/** @var string */
public $title;
/** @var bool */
public $published;
/** @var \DateTimeInterface */
public $created_at;
class ArticleEntity extends YourBaseEntity
{
public const TABLE_NAME = 'articles';
public const ID = 'id';
public const TITLE = 'title';
public const PUBLISHED = 'published';
public const CREATED_AT = 'created_at';
.
.
.
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.