Справочник API

Полный справочник по публичным классам и интерфейсам.

Содержание

Модель схемы

Schema

final readonly class Schema
{
    /** @var array<string, Table> */
    public array $tables;
    public function hasTable(string $name): bool;
    public function getTable(string $name): ?Table;
}

Table

final readonly class Table
{
    public string $name;
    /** @var array<string, Column> */
    public array $columns;
    /** @var list<string> */
    public array $primaryKey;
    /** @var array<string, Index> */
    public array $indexes;
    /** @var array<string, ForeignKey> */
    public array $foreignKeys;
}

Column

final readonly class Column
{
    public string $name;
    public ColumnType $type;
    public bool $nullable;
    public mixed $default;
    public bool $primaryKey;
    public bool $autoIncrement;
    public ?int $length;
    public ?int $precision;
    public ?int $scale;
    public bool $unsigned;
    public ?string $comment;
    /** @var list<string> */
    public array $enumValues;
}

ColumnType (enum)

Значения: integer, smallint, bigint, string, text, boolean, decimal, float, double, datetime, date, time, timestamp, uuid, json, binary, enum.


Парсер

SchemaParserInterface

interface SchemaParserInterface
{
    public function parse(string $path): Schema;
}

Реализации: PhpSchemaParser (по умолчанию), YamlSchemaParser (требует symfony/yaml).


Дифф

SchemaDiffer

final class SchemaDiffer
{
    /** @return list<OperationInterface> */
    public function diff(Schema $from, Schema $to): array;
}

Операции

CreateTable, DropTable, AddColumn, DropColumn, AlterColumn, AddIndex, DropIndex, AddForeignKey, DropForeignKey.


Платформа

PlatformInterface

interface PlatformInterface
{
    /** @return list<string> */
    public function toSql(OperationInterface $operation): array;
    public function supportsDdlTransactions(): bool;
}

Реализации: MysqlPlatform, PostgresPlatform, SqlitePlatform.


Интроспектор

IntrospectorInterface

interface IntrospectorInterface
{
    public function introspect(\PDO $pdo): Schema;
}

Маппер типов

TypeMapperInterface

interface TypeMapperInterface
{
    public function toSqlType(Column $column): string;
    public function toAbstractType(string $sqlType): ColumnType;
}

Миграции

MigrationInterface

interface MigrationInterface
{
    public function up(SchemaBuilder $schema): void;
    public function down(SchemaBuilder $schema): void;
}

MigrationRepositoryInterface

interface MigrationRepositoryInterface
{
    /** @return list<string> */
    public function getApplied(): array;
    public function markApplied(string $version): void;
    public function markRolledBack(string $version): void;
    public function ensureTable(): void;
}

Pdo

PdoDriverResolver

final class PdoDriverResolver
{
    public function resolve(\PDO $pdo): string;
}

Общий сервис для определения драйвера PDO, используемый в IntrospectorFactory и PlatformFactory.