barbarossa42/nextras-orm-command

This package is abandoned and no longer maintained. No replacement package was suggested.

Console command for Nextras/ORM

v1.0 2018-03-23 12:23 UTC

This package is not auto-updated.

Last update: 2020-01-24 01:27:19 UTC


README

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