SchemaExporter
in package
Exports database schema to YAML format for reference purposes Similar to Rails' schema.rb functionality
Table of Contents
Properties
- $_Adapter : AdapterInterface
- $_AdapterType : string
- $_MigrationTable : string
- $fs : IFileSystem
Methods
- __construct() : mixed
- __destruct() : mixed
- Destructor - ensure adapter is disconnected
- disconnect() : void
- Disconnect from database
- export() : string
- Export schema to YAML string
- exportToFile() : bool
- Export schema to file
- buildSchemaArray() : array<string|int, mixed>
- Build schema array structure
- getColumns() : array<string|int, mixed>
- Get columns for a table
- getColumnsMysql() : array<string|int, mixed>
- Get columns for MySQL
- getColumnsPostgres() : array<string|int, mixed>
- Get columns for PostgreSQL
- getColumnsSqlite() : array<string|int, mixed>
- Get columns for SQLite
- getForeignKeys() : array<string|int, mixed>
- Get foreign keys for a table
- getForeignKeysMysql() : array<string|int, mixed>
- Get foreign keys for MySQL
- getForeignKeysPostgres() : array<string|int, mixed>
- Get foreign keys for PostgreSQL
- getForeignKeysSqlite() : array<string|int, mixed>
- Get foreign keys for SQLite
- getIndexes() : array<string|int, mixed>
- Get indexes for a table
- getIndexesMysql() : array<string|int, mixed>
- Get indexes for MySQL
- getIndexesPostgres() : array<string|int, mixed>
- Get indexes for PostgreSQL
- getIndexesSqlite() : array<string|int, mixed>
- Get indexes for SQLite
- getLatestMigrationVersion() : string|null
- Get latest migration version from tracking table
- getTables() : array<string|int, mixed>
- Get list of all tables in database
- getTableSchema() : array<string|int, mixed>
- Get schema for a specific table
- normalizeType() : string
- Normalize column type names
Properties
$_Adapter
private
AdapterInterface
$_Adapter
$_AdapterType
private
string
$_AdapterType
$_MigrationTable
private
string
$_MigrationTable
$fs
private
IFileSystem
$fs
Methods
__construct()
public
__construct(Config $PhinxConfig, string $Environment[, string $MigrationTable = 'phinx_log' ][, IFileSystem|null $fs = null ]) : mixed
Parameters
- $PhinxConfig : Config
-
Phinx configuration
- $Environment : string
-
Environment name
- $MigrationTable : string = 'phinx_log'
-
Migration tracking table name
- $fs : IFileSystem|null = null
-
File system implementation (null = use real file system)
__destruct()
Destructor - ensure adapter is disconnected
public
__destruct() : mixed
disconnect()
Disconnect from database
public
disconnect() : void
export()
Export schema to YAML string
public
export() : string
Return values
string —YAML representation of schema
exportToFile()
Export schema to file
public
exportToFile(string $FilePath) : bool
Parameters
- $FilePath : string
-
Path to output file
Return values
bool —Success status
buildSchemaArray()
Build schema array structure
private
buildSchemaArray() : array<string|int, mixed>
Return values
array<string|int, mixed>getColumns()
Get columns for a table
private
getColumns(string $tableName) : array<string|int, mixed>
Parameters
- $tableName : string
Return values
array<string|int, mixed>getColumnsMysql()
Get columns for MySQL
private
getColumnsMysql(string $tableName) : array<string|int, mixed>
Parameters
- $tableName : string
Return values
array<string|int, mixed>getColumnsPostgres()
Get columns for PostgreSQL
private
getColumnsPostgres(string $tableName) : array<string|int, mixed>
Parameters
- $tableName : string
Return values
array<string|int, mixed>getColumnsSqlite()
Get columns for SQLite
private
getColumnsSqlite(string $tableName) : array<string|int, mixed>
Parameters
- $tableName : string
Return values
array<string|int, mixed>getForeignKeys()
Get foreign keys for a table
private
getForeignKeys(string $tableName) : array<string|int, mixed>
Parameters
- $tableName : string
Return values
array<string|int, mixed>getForeignKeysMysql()
Get foreign keys for MySQL
private
getForeignKeysMysql(string $tableName) : array<string|int, mixed>
Parameters
- $tableName : string
Return values
array<string|int, mixed>getForeignKeysPostgres()
Get foreign keys for PostgreSQL
private
getForeignKeysPostgres(string $tableName) : array<string|int, mixed>
Parameters
- $tableName : string
Return values
array<string|int, mixed>getForeignKeysSqlite()
Get foreign keys for SQLite
private
getForeignKeysSqlite(string $tableName) : array<string|int, mixed>
Parameters
- $tableName : string
Return values
array<string|int, mixed>getIndexes()
Get indexes for a table
private
getIndexes(string $tableName) : array<string|int, mixed>
Parameters
- $tableName : string
Return values
array<string|int, mixed>getIndexesMysql()
Get indexes for MySQL
private
getIndexesMysql(string $tableName) : array<string|int, mixed>
Parameters
- $tableName : string
Return values
array<string|int, mixed>getIndexesPostgres()
Get indexes for PostgreSQL
private
getIndexesPostgres(string $tableName) : array<string|int, mixed>
Parameters
- $tableName : string
Return values
array<string|int, mixed>getIndexesSqlite()
Get indexes for SQLite
private
getIndexesSqlite(string $tableName) : array<string|int, mixed>
Parameters
- $tableName : string
Return values
array<string|int, mixed>getLatestMigrationVersion()
Get latest migration version from tracking table
private
getLatestMigrationVersion() : string|null
Return values
string|nullgetTables()
Get list of all tables in database
private
getTables() : array<string|int, mixed>
Return values
array<string|int, mixed>getTableSchema()
Get schema for a specific table
private
getTableSchema(string $tableName) : array<string|int, mixed>
Parameters
- $tableName : string
Return values
array<string|int, mixed>normalizeType()
Normalize column type names
private
normalizeType(string $type) : string
Parameters
- $type : string