Skip to content

universe-42/nextras-orm-command

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Please use contributte/nextras-orm-generator instead.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages