inlm / schema-generator-leanmapper
Lean Mapper bridge for inlm/schema-generator
Fund package maintenance!
Other
Requires
- php: >=5.6.0
- inlm/schema-generator: ^1.0
- inlm/schema-generator-dibi: ^1.0
- tharos/leanmapper: ^3.0 || ^4.0
Requires (Dev)
- nette/tester: ^2.0
This package is auto-updated.
Last update: 2024-11-28 10:13:04 UTC
README
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/