composer require barbarossa42/nextras-orm-command
Using Kdyby\Console, don´t forget to config file
Nette neon config example:
console:
commands:
- Barbarossa42\NextrasOrmCommand\CreateOrmCommand
create:orm article Articles\Article articles
will generate 3 files in folder Article (into specific directory):
Article.php
namespace App\Orm\Articles\Article;
use Nextras\Orm\Entity\Entity;
/**
* Article Entity class
* @property int $id {primary}
*/
class Article extends Entity
{
}
ArticleRepository.php
namespace App\Orm\Articles\Article;
use Nextras\Orm\Repository\Repository;
class ArticleRepository extends Repository
{
public static function getEntityClassNames(): array
{
return [Article::class];
}
}
ArticleMapper.php
namespace App\Orm\Articles\Article;
use Nextras\Orm\Mapper\Mapper;
class ArticleMapper extends Mapper
{
protected $tableName = 'articles';
}
[0] command name
[1] entity name
[2] namespace (optional)
[3] table name (optional)
You can setup your custom extends Parents. For Example custom entity:
const NS_ENTITY = 'App\Core\Entity';