cycle / schema-builder
Cycle ORM Schema Builder
Fund package maintenance!
2.13.0
2026-11-21 12:19 UTC
Requires
- php: >=8.2
- cycle/database: ^2.24
- cycle/orm: ^2.19
- yiisoft/friendly-exception: ^1.1
Requires (Dev)
- bamarni/composer-bin-plugin: ^1.9
- buggregator/trap: ^1.20
- cycle/testing: ^0.1.2
- llm/skills: ^1.20
- mockery/mockery: ^1.6
- roxblnfk/unpoly: ^1.8
- testo/bridge-mockery: ^0.1.2
- testo/testo: ^0.10.60
Suggests
None
Provides
None
Conflicts
None
Replaces
None
- 2.x-dev
- 2.13.0
- 2.12.2
- 2.12.1
- v2.12.0
- v2.11.2
- v2.11.1
- v2.11.0
- v2.10.0
- v2.9.0
- v2.8.0
- v2.7.0
- v2.6.2
- v2.6.1
- v2.6.0
- v2.5.1
- v2.5.0
- v2.4.0
- v2.3.0
- v2.2.0
- v2.1.0
- v2.0.1
- v2.0.0
- 1.x-dev
- v1.2.1
- v1.2.0
- v1.1.23
- v1.1.22
- v1.1.21
- v1.1.20
- v1.1.19
- v1.1.18
- v1.1.17
- v1.1.16
- v1.1.15
- v1.1.4
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.11
- v1.0.10
- v1.0.9
- v1.0.8
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- v0.1
This package is auto-updated.
Last update: 2026-11-22 10:15:53 UTC
README
Cycle ORM Schema Builder
Schema Builder configures the Cycle ORM and database schema from entity definitions, produced by annotations (attributes) or by custom generators.
Get Started
Installation
composer require cycle/schema-builder
Requires PHP 8.2+.
Configuration
use Cycle\Database; use Cycle\Database\Config; $dbal = new Database\DatabaseManager(new Config\DatabaseConfig([ 'default' => 'default', 'databases' => [ 'default' => [ 'connection' => 'sqlite' ] ], 'connections' => [ 'sqlite' => new Config\SQLiteDriverConfig( connection: new Config\SQLite\MemoryConnectionConfig(), queryCache: true, ), ] ])); $registry = new \Cycle\Schema\Registry($dbal);
Registering entities
Register an entity, add its columns and link it to a table:
use Cycle\Schema\Definition; $entity = new Definition\Entity(); $entity ->setRole('user') ->setClass(User::class); // add fields $entity->getFields() ->set('id', (new Definition\Field())->setType('primary')->setColumn('id')->setPrimary(true)) ->set('name', (new Definition\Field())->setType('string(32)')->setColumn('user_name')); // register entity $registry->register($entity); // associate table $registry->linkTable($entity, 'default', 'users');
Compiling the schema
Generate the ORM schema with Cycle\Schema\Compiler:
use Cycle\Schema\Compiler; $schema = (new Compiler())->compile($registry); $orm = $orm->with(schema: new \Cycle\ORM\Schema($schema));
More about the Schema Builder is in the documentation.
Testing
The tests run on Testo through the shared cycle/testing harness: tests/Unit needs no database, and tests/Feature runs once per database driver.
composer test:unit # no database composer test:sqlite # in-memory SQLite, no docker composer db:up # MySQL, Postgres and SQL Server in docker composer test # every suite; a driver whose server is down is skipped composer db:down
composer test:mysql, test:postgres and test:sqlserver run one driver.