Skip to content

Latest commit

 

History

History
79 lines (58 loc) · 1.28 KB

README.md

File metadata and controls

79 lines (58 loc) · 1.28 KB

Nextras/Orm -Console command

composer require barbarossa42/nextras-orm-command

Configuration

Using Kdyby\Console, don´t forget to config file

Nette neon config example:

console:
    commands:
        - Barbarossa42\NextrasOrmCommand\CreateOrmCommand

Usage

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';
}

Command syntax

[0] command name

[1] entity name

[2] namespace (optional)

[3] table name (optional)

Config constants

You can setup your custom extends Parents. For Example custom entity:

const NS_ENTITY = 'App\Core\Entity';