{"id":15030039,"url":"https://github.com/hectororm/schema","last_synced_at":"2025-04-09T20:41:13.767Z","repository":{"id":62515339,"uuid":"333216503","full_name":"hectororm/schema","owner":"hectororm","description":"Hector Schema is the schema generator module of Hector ORM. Can be used independently of ORM.","archived":false,"fork":false,"pushed_at":"2025-03-14T13:15:01.000Z","size":2375,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-23T22:37:12.393Z","etag":null,"topics":["orm","pdo","php","php8","schema","sql"],"latest_commit_sha":null,"homepage":"https://gethectororm.com","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hectororm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-01-26T21:02:47.000Z","updated_at":"2025-03-14T13:12:24.000Z","dependencies_parsed_at":"2024-09-28T20:40:43.198Z","dependency_job_id":"a1fe590d-d44c-4346-ad15-60621ea3b130","html_url":"https://github.com/hectororm/schema","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hectororm%2Fschema","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hectororm%2Fschema/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hectororm%2Fschema/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hectororm%2Fschema/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hectororm","download_url":"https://codeload.github.com/hectororm/schema/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248109748,"owners_count":21049364,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["orm","pdo","php","php8","schema","sql"],"created_at":"2024-09-24T20:12:17.735Z","updated_at":"2025-04-09T20:41:13.742Z","avatar_url":"https://github.com/hectororm.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hector Schema\n\n[![Latest Version](https://img.shields.io/packagist/v/hectororm/schema.svg?style=flat-square)](https://github.com/hectororm/schema/releases)\n[![Software license](https://img.shields.io/github/license/hectororm/schema.svg?style=flat-square)](https://github.com/hectororm/schema/blob/main/LICENSE)\n[![Build Status](https://img.shields.io/github/actions/workflow/status/hectororm/schema/tests.yml?branch=main\u0026style=flat-square)](https://github.com/hectororm/schema/actions/workflows/tests.yml?query=branch%3Amain)\n[![Quality Grade](https://img.shields.io/codacy/grade/7a46b10dec0a43268fab3de12d0f0529/main.svg?style=flat-square)](https://app.codacy.com/gh/hectororm/schema)\n[![Total Downloads](https://img.shields.io/packagist/dt/hectororm/schema.svg?style=flat-square)](https://packagist.org/packages/hectororm/schema)\n\n**Hector Schema** is the schema generator module of Hector ORM. Can be used independently of ORM.\n\n## Installation\n\n### Composer\n\nYou can install **Hector Schema** with [Composer](https://getcomposer.org/), it's the recommended installation.\n\n```bash\n$ composer require hectororm/schema\n```\n\n### Dependencies\n\n* **PHP** ^8.0\n* Packages dependencies:\n  * **hectororm/connection**\n\n## DBMS compatibility\n\n| DBMS    | Version | Compatibility |\n|---------|:-------:|:-------------:|\n| MySQL   |   8.0   |       ✔       |\n| MySQL   |   5.7   |       ✔       |\n| MySQL   |   5.6   |       ✔       |\n| MySQL   |   5.5   |       ?       |\n| MariaDB |  10.6   |       ✔       |\n| MariaDB |  10.5   |       ✔       |\n| MariaDB |  10.4   |       ✔       |\n| MariaDB |  10.3   |       ✔       |\n| MariaDB |  10.2   |       ?       |\n| Sqlite  |   3.x   |       ✔       |\n\nIf you have any information on the compatibility of other versions, feel free to make a PR. \n\n## Usage\n\n### Generate a schema\n\n```php\nuse Hector\\Connection\\Connection;\nuse Hector\\Schema\\Generator\\MySQL;\n\n$connection = new Connection('...');\n$generator = new MySQL($connection);\n\n$schema = $generator-\u003egenerateSchema('schema_name'); // Returns a `Hector\\Schema\\Schema` object\n$container = $generator-\u003egenerateSchemas('schema1_name', 'schema2_name'); // Returns a `Hector\\Schema\\SchemaContainer` object\n```\n\nGenerators:\n\n- `Hector\\Schema\\Generato\\MySQL` for MySQL or derived DBMS\n- `Hector\\Schema\\Generato\\Sqlite` for Sqlite\n\n### Cache\n\nThis library don't provide cache management for schemas.\nIt's to the user library to imagine how store the generated schema.\n\nTo help to do that, library only provide serialization of objects and restoration of inheritance between objects.\n\n### Schema\n\nDescription of classes represents the a schema.\n\n#### `Hector\\Schema\\SchemaContainer`\n\nIt's a container of schema. Methods available:\n\n- `SchemaContainer::getSchemas(?string $connection = null): Generator` Returns a generator of `Hector\\Schema\\Schema` objects, you can pass a specific connection\n- `SchemaContainer::hasSchema(string $name, ?string $connection = null): bool` Check if container has a schema\n- `SchemaContainer::getSchema(string $name, ?string $connection = null): Schema` Returns representation of a schema, an `Hector\\Schema\\Schema` object\n- `SchemaContainer::hasTable(string $name, ?string $schemaName = null, ?string $connection = null): bool` Check if a schema in the container has a table\n- `SchemaContainer::getTable(string $name, ?string $schemaName = null, ?string $connection = null): Table` Returns representation of a table, an `Hector\\Schema\\Table` object\n\nIt's an iterable class, returns `Hector\\Schema\\Schema` objects.\n\n#### `Hector\\Schema\\Schema`\n\nRepresent a schema. Methods available:\n\n- `Schema::getName(bool $quoted = false): string` Returns the name of schema\n- `Schema::getCharset(): string` Returns the charset of schema\n- `Schema::getCollation(): string` Returns the charset of schema\n- `Schema::getTables(): Generator` Returns a generator of `Hector\\Schema\\Table` objects\n- `Schema::hasTable(string $name): bool` Check if schema has a table\n- `Schema::getTable(string $name): Table` Returns representation of a table, an `Hector\\Schema\\Table` object\n- `Schema::getContainer(): ?SchemaContainer` Returns the container of schema if it's a part of a container\n\nIt's an iterable class, returns `Hector\\Schema\\Table` objects.\n\n#### `Hector\\Schema\\Table`\n\nRepresent a table of a schema. Methods available:\n\n- `Table::getSchemaName(bool $quoted = false): string`\n- `Table::getName(bool $quoted = false): string`\n- `Table::getFullName(bool $quoted = false): string`\n- `Table::getType(): string`\n- `Table::getCharset(): ?string`\n- `Table::getCollation(): ?string`\n- `Table::getColumns(): Generator`\n- `Table::getColumnsName(bool $quoted = false, ?string $tableAlias = null): array`\n- `Table::hasColumn(string $name): bool`\n- `Table::getColumn(string $name): Column`\n- `Table::getAutoIncrementColumn(): ?Column`\n- `Table::getIndexes(?string $type = null): Generator`\n- `Table::hasIndex(string $name): bool`\n- `Table::getIndex(string $name): Index`\n- `Table::getPrimaryIndex(): ?Index`\n- `Table::getForeignKeys(Table $table = null): Generator`\n- `Table::getSchema(): Schema`\n\n#### `Hector\\Schema\\Column`\n\nRepresent a column of a table. Methods available:\n\n- `Column::getName(bool $quoted = false, ?string $tableAlias = null): string`\n- `Column::getFullName(bool $quoted = false): string`\n- `Column::getPosition(): int`\n- `Column::getDefault(): mixed`\n- `Column::isNullable(): bool`\n- `Column::getType(): string`\n- `Column::isAutoIncrement(): bool`\n- `Column::getMaxlength(): ?int`\n- `Column::getNumericPrecision(): ?int`\n- `Column::getNumericScale(): ?int`\n- `Column::isUnsigned(): bool`\n- `Column::getCharset(): ?string`\n- `Column::getCollation(): ?string`\n- `Column::getTable(): Table`\n- `Column::isPrimary(): bool`\n\n#### `Hector\\Schema\\Index`\n\nRepresent an index of a table. Methods available:\n\n- `Index::getName(): string`\n- `Index::getType(): string`\n- `Index::getColumnsName(bool $quoted = false, ?string $tableAlias = null): array`\n- `Index::getTable(): Table`\n- `Index::getColumns(): array`\n- `Index::hasColumn(Column $column): bool`\n\n#### `Hector\\Schema\\ForeignKey`\n\nRepresent a foreign key of a table. Methods available:\n\n- `ForeignKey::getName(): string`\n- `ForeignKey::getColumnsName(bool $quoted = false, ?string $tableAlias = null): array`\n- `ForeignKey::getReferencedSchemaName(): string`\n- `ForeignKey::getReferencedTableName(): string`\n- `ForeignKey::getReferencedColumnsName(bool $quoted = false, ?string $tableAlias = null): array`\n- `ForeignKey::getUpdateRule(): string`\n- `ForeignKey::getDeleteRule(): string`\n- `ForeignKey::getTable(): Table`\n- `ForeignKey::getColumns(): Generator`\n- `ForeignKey::getReferencedTable(): ?Table`\n- `ForeignKey::getReferencedColumns(): Generator`","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhectororm%2Fschema","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhectororm%2Fschema","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhectororm%2Fschema/lists"}