composer require martenb/nextras-orm-code-generator:dev-master --dev
extensions:
ormGenerator: MartenB\Nextras\ORM\DI\Extension
ormGenerator:
directory: '%appDir%/Model/Orm'
namespace: 'App\Model\Orm'
entityExtends: 'App\Model\Orm\BaseEntity'
repositoryExtends: 'App\Model\Orm\BaseRepository'
mapperExtends: 'App\Model\Orm\BaseMapper'
php bin/console orm:generator Product Products
This command creates entity, repository and mapper in %directory%/Product
.
<?php
namespace App\Model\Orm\Product;
/**
* @property int $id {primary}
*/
class Product extends BaseEntity
{
}
<?php
namespace App\Model\Orm\Product;
class ProductsRepository extends BaseRepository
{
public static function getEntityClassNames(): array
{
return [Product::class];
}
}
<?php
namespace App\Model\Orm\Product;
class ProductsMapper extends BaseMapper
{
}