PHPackages                             fyre/schema - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. fyre/schema

ActiveLibrary[Database &amp; ORM](/categories/database)

fyre/schema
===========

A database schema library.

v8.0.3(7mo ago)0467↓83.3%3MITPHP

Since Jan 16Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/elusivecodes/FyreSchema)[ Packagist](https://packagist.org/packages/fyre/schema)[ RSS](/packages/fyre-schema/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (10)Dependencies (9)Versions (56)Used By (3)

FyreSchema
==========

[](#fyreschema)

**FyreSchema** is a free, open-source database schema library for *PHP*.

Table Of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Basic Usage](#basic-usage)
- [Methods](#methods)
- [Schemas](#schemas)
- [Tables](#tables)
    - [MySQL Tables](#mysql-tables)
- [Columns](#columns)
    - [MySQL Columns](#mysql-columns)
- [Indexes](#indexes)
- [Foreign Keys](#foreign-keys)

Installation
------------

[](#installation)

**Using Composer**

```
composer require fyre/schema

```

In PHP:

```
use Fyre\Schema\SchemaRegistry;
```

Basic Usage
-----------

[](#basic-usage)

- `$container` is a [*Container*](https://github.com/elusivecodes/FyreContainer).

```
$schemaRegistry = new SchemaRegistry($container);
```

**Autoloading**

It is recommended to bind the *SchemaRegistry* to the [*Container*](https://github.com/elusivecodes/FyreContainer) as a singleton.

```
$container->singleton(SchemaRegistry::class);
```

Any dependencies will be injected automatically when loading from the [*Container*](https://github.com/elusivecodes/FyreContainer).

```
$schemaRegistry = $container->use(SchemaRegistry::class);
```

Methods
-------

[](#methods)

**Map**

Map a [*Connection*](https://github.com/elusivecodes/FyreDB#connections) class to a [*Schema*](#schemas) handler.

- `$connectionClass` is a string representing the [*Connection*](https://github.com/elusivecodes/FyreDB#connections) class name.
- `$schemaClass` is a string representing the [*Schema*](#schemas) class name.

```
$schemaRegistry->map($connectionClass, $schemaClass);
```

**Use**

Load the shared [*Schema*](#schemas) for a [*Connection*](https://github.com/elusivecodes/FyreDB#connections).

- `$connection` is a [*Connection*](https://github.com/elusivecodes/FyreDB#connections).

```
$schema = $schemaRegistry->use($connection);
```

[*Schema*](#schemas) dependencies will be resolved automatically from the [*Container*](https://github.com/elusivecodes/FyreContainer).

Schemas
-------

[](#schemas)

**Clear**

Clear the table data (including cache).

```
$schema->clear();
```

**Get Connection**

Get the [*Connection*](https://github.com/elusivecodes/FyreDB#connections).

```
$connection = $schema->getConnection();
```

**Get Database Name**

Get the database name.

```
$database = $schema->getDatabaseName();
```

**Has Table**

Determine whether the schema has a table.

- `$name` is a string representing the table name.

```
$hasTable = $schema->hasTable($name);
```

**Table**

Load a [*Table*](#tables).

- `$name` is a string representing the table name.

```
$table = $schema->table($name);
```

**Table Names**

Get the names of all schema tables.

```
$tableNames = $schema->tableNames();
```

**Tables**

Load all schema tables.

```
$tables = $schema->tables();
```

This method will return a [*Collection*](https://github.com/elusivecodes/FyreCollection) containing the loaded [tables](#tables).

Tables
------

[](#tables)

**Clear**

Clear the table data (including cache).

```
$table->clear();
```

**Column**

Load a [*Column*](#columns).

- `$name` is a string representing the column name.

```
$column = $table->column($name);
```

**Column Names**

Get the names of all table columns.

```
$columnNames = $table->columnNames();
```

**Columns**

Load all table columns.

```
$columns = $table->columns();
```

This method will return a [*Collection*](https://github.com/elusivecodes/FyreCollection) containing the loaded [columns](#columns).

**Foreign Key**

Load a [*ForeignKey*](#foreign-keys).

- `$name` is a string representing the foreign key name.

```
$foreignKey = $table->foreignKey($name);
```

**Foreign Keys**

Load all table foreign keys.

```
$foreignKeys = $table->foreignKeys();
```

This method will return a [*Collection*](https://github.com/elusivecodes/FyreCollection) containing the loaded [foreign keys](#foreign-keys).

**Get Comment**

Get the table comment.

```
$comment = $table->getComment();
```

**Get Name**

Get the table name.

```
$name = $table->getName();
```

**Get Schema**

Get the [*Schema*](#schemas).

```
$schema = $table->getSchema();
```

**Has Auto Increment**

Determine whether the table has an auto increment column.

```
$hasAutoIncrement = $table->hasAutoIncrement();
```

**Has Column**

Determine whether the table has a column.

- `$name` is a string representing the column name.

```
$hasColumn = $table->hasColumn($name);
```

**Has Foreign Key**

Determine whether the table has a foreign key.

- `$name` is a string representing the foreign key name.

```
$hasForeignKey = $table->hasForeignKey($name);
```

**Has Index**

Determine whether the table has an index.

- `$name` is a string representing the index name.

```
$hasIndex = $table->hasIndex($name);
```

**Index**

Load an [*Index*](#indexes).

- `$name` is a string representing the index name.

```
$index = $table->index($name);
```

**Indexes**

Load all table indexes.

```
$indexes = $table->indexes();
```

This method will return a [*Collection*](https://github.com/elusivecodes/FyreCollection) containing the loaded [indexes](#indexes).

**Primary Key**

Get the primary key for the table.

```
$primaryKey = $table->primaryKey();
```

**To Array**

Get the table data as an array.

```
$data = $table->toArray();
```

### MySQL Tables

[](#mysql-tables)

**Get Charset**

Get the table character set.

```
$charset = $table->getCharset();
```

**Get Collation**

Get the table collation.

```
$collation = $table->getCollation();
```

**Get Engine**

Get the table engine.

```
$engine = $table->getEngine();
```

Columns
-------

[](#columns)

**Default Value**

Get the evaluated default value for a column.

```
$defaultValue = $column->defaultValue();
```

**Get Comment**

Get the column comment.

```
$comment = $column->getComment();
```

**Get Default**

Get the column default value.

```
$default = $column->getDefault();
```

**Get Length**

Get the column length.

```
$length = $column->getLength();
```

**Get Name**

Get the column name.

```
$name = $column->getName();
```

**Get Precision**

Get the column precision.

```
$precision = $column->getPrecision();
```

**Get Table**

Get the [*Table*](#tables).

```
$table = $column->getTable();
```

**Get Type**

Get the column type.

```
$type = $column->getType();
```

**Is Auto Increment**

Determine whether the column is an auto increment column.

```
$isAutoIncrement = $column->isAutoIncrement();
```

**Is Nullable**

Determine whether the column is nullable.

```
$isNullable = $column->isNullable();
```

**Is Unsigned**

Determine whether the column is unsigned.

```
$isUnsigned = $column->isUnsigned();
```

**To Array**

Get the column data as an array.

```
$data = $column->toArray();
```

**Type**

Get the type parser for the column.

```
$typeParser = $column->type();
```

### MySQL Columns

[](#mysql-columns)

**Get Charset**

Get the column character set.

```
$charset = $column->getCharset();
```

**Get Collation**

Get the column collation.

```
$collation = $column->getCollation();
```

**Get Values**

Get the column enum values.

```
$values = $column->getValues();
```

Indexes
-------

[](#indexes)

**Get Columns**

Get the column names.

```
$columns = $index->getColumns();
```

**Get Name**

Get the index name.

```
$name = $index->getName();
```

**Get Table**

Get the [*Table*](#tables).

```
$table = $index->getTable();
```

**Get Type**

Get the index type.

```
$type = $index->getType();
```

**Is Primary**

Determine whether the index is primary.

```
$isPrimary = $index->isPrimary();
```

**Is Unique**

Determine whether the index is unique.

```
$isUnique = $index->isUnique();
```

**To Array**

Get the index data as an array.

```
$data = $index->toArray();
```

Foreign Keys
------------

[](#foreign-keys)

**Get Columns**

Get the column names.

```
$columns = $foreignKey->getColumns();
```

**Get Name**

Get the foreign key name.

```
$name = $foreignKey->getName();
```

**Get On Delete**

Get the delete action.

```
$onDelete = $foreignKey->getOnDelete();
```

**Get On Update**

Get the update action.

```
$onUpdate = $foreignKey->getOnUpdate();
```

**Get Referenced Columns**

Get the referenced column names.

```
$referencedColumn = $foreignKey->getReferencedColumns();
```

**Get Referenced Table**

Get the referenced table name.

```
$referencedTable = $foreignKey->getReferencedTable();
```

**Get Table**

Get the [*Table*](#tables).

```
$table = $foreignKey->getTable();
```

**To Array**

Get the foreign key data as an array.

```
$data = $foreignKey->toArray();
```

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance63

Regular maintenance activity

Popularity12

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 97.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~25 days

Recently: every ~12 days

Total

55

Last Release

228d ago

Major Versions

v3.1.2 → v4.02024-07-12

v4.2.4 → v5.02024-11-01

v5.0.1 → v6.02024-11-02

v6.0.13 → v7.02025-09-07

v7.0.2 → v8.02025-10-29

### Community

Maintainers

![](https://www.gravatar.com/avatar/fad81fd5941e3a637c8a5749d05ae3ed9314d5e2fee57f59c3d9ec3b41259c6b?d=identicon)[elusivecodes](/maintainers/elusivecodes)

---

Top Contributors

[![elusivecodes](https://avatars.githubusercontent.com/u/18050480?v=4)](https://github.com/elusivecodes "elusivecodes (46 commits)")[![pm-michael](https://avatars.githubusercontent.com/u/49225527?v=4)](https://github.com/pm-michael "pm-michael (1 commits)")

---

Tags

databasemysqlphppostgreqlschemasqlite

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/fyre-schema/health.svg)

```
[![Health](https://phpackages.com/badges/fyre-schema/health.svg)](https://phpackages.com/packages/fyre-schema)
```

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k116.5M113](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
