Statistics
866
3
1
112d
Badges
Dependencies

LeanMapper-extension

LeanMapper extension for Nette.

Installation

Download a latest package or use Composer:

composer require janpecha/leanmapper-extension

Extension requires:

  • PHP 5.3 or later
  • Nette 2.2 or later
  • LeanMapper 2.2 or later

Usage

extensions:
	leanmapper: JP\LeanMapperExtension\LeanMapperExtension


leanmapper:
	# database connection
	username: ...
	password: ...
	database: ...

Configuration

Database connection

leanmapper:
	# required
	username: ...
	password: ...
	database: ...

	# optional
	connection: LeanMapper\Connection
	host: localhost
	driver: mysqli
	lazy: true
	profiler: ...    # on|off or NULL => enabled in debug mode, disabled in production mode

Entities

leanmapper:
	entityFactory: LeanMapper\DefaultEntityFactory
	entities:
		table: EntityClass

		table:
			entity: EntityClass
			repository: RepositoryClass # repository is auto-registred in DI container
			primaryKey: table_primary_key

		articles:
			entity: App\Model\Article
			primaryKey: article_id

Mapper

leanmapper:
	mapper: JP\LeanMapperExtension\Mapper
	defaultEntityNamespace: 'Model\Entity'

Support for addons

<?php
use Nette\DI\CompilerExtension;
use JP\LeanMapperExtension\IEntityProvider;

class FooExtension extends CompilerExtension implements IEntityProvider
{
	// from IEntityProvider
	function getEntityMappings()
	{
		return array(
			array(
				'table' => 'foo_articles',
				'primaryKey' => 'id',
				'entity' => 'Foo\Model\Article',
				'repository' => 'Foo\Model\ArticleRepository', # repository is auto-registred in DI container, see option 'registerRepository'
				'registerRepository' => TRUE, // optional
			),
			// ...
		);
	}
}
?>

Mapper (for experts)

<?php
$mapper = JP\LeanMapperExtension\Mapper($defaultEntityNamespace = NULL);

// register entity
$mapper->register($tableName, $entity = NULL, $repository = NULL, $primaryKey = NULL);
?>

License: New BSD License
Author: Jan Pecha, http://janpecha.iunas.cz/

  • v0.9.2 Version 0.9.2

    • Composer: added tharos/leanmapper 3.x
    • Composer: updated constraints
    • updated coding-style
    • Travis CI: added PHP 7.1
    • Travis CI: updated
    • Tests: added Makefile
  • v0.9.1 Version 0.9.1

    • minor fixes, typos
  • v0.9.0 Version 0.9.0

    First public release

Is this addon outdated? Did you find an issue? Please report it.

Componette Componette admin@componette.com