inlm/schema-generator-leanmapper

Lean Mapper bridge for inlm/schema-generator

v1.0.0 2023-07-28 07:18 UTC

This package is auto-updated.

Last update: 2024-10-28 09:57:39 UTC


README

Build Status Downloads this Month Latest Stable Version License

Donate

Installation

Download a latest package or use Composer:

composer require inlm/schema-generator-leanmapper

Schema Generator requires PHP 5.6.0 or later.

Usage

$extractor = new Inlm\SchemaGenerator\LeanMapperBridge\LeanMapperExtractor(__DIR__ . '/model/Entities/', new LeanMapper\DefaultMapper);
$adapter = new Inlm\SchemaGenerator\Adapters\NeonAdapter(__DIR__ . '/.schema.neon');
$dumper = new Inlm\SchemaGenerator\Dumpers\SqlDumper(__DIR__ . '/migrations/structures/');
$logger = new Inlm\SchemaGenerator\Loggers\MemoryLogger;

$generator = new Inlm\SchemaGenerator\SchemaGenerator($extractor, $adapter, $dumper, $logger, Inlm\SchemaGenerator\Database::MYSQL);
// $generator->setTestMode();

$generator->generate();
// or
$generator->generate('changes description');

Documentation

LeanMapperExtractor generates schema from Lean Mapper entities.

$directories = '/path/to/model/Entities/';
// or
$directories = [
	'/path/to/model/Entities/',
	'/path/to/package/Entities/',
];

$mapper = new LeanMapper\DefaultMapper;
$extractor = new Inlm\SchemaGenerator\LeanMapperBridge\LeanMapperExtractor($directories, $mapper);

Flags

@property string|NULL $web m:schemaType(varchar:50)

If primary column is integer (@property int $id), automatically gets AUTO_INCREMENT.

Flag m:schemaType can be used with custom types too - for example m:schemaType(money) or m:schemaType(money unsigned).

In case if is flag m:schemaType missing, it uses default type or your custom type.

Annotations

You can define default table options globally.

Example

/**
 * @property int $id
 * @property string $name m:schemaType(varchar:100)
 * @schemaOption COLLATE utf8_czech_ci
 */
class Author extends \LeanMapper\Entity
{
}

License: New BSD License
Author: Jan Pecha, https://www.janpecha.cz/