ORM Commands

ORM Commands

ORM commands facilitate the management of the Object-Relational Mapping layer, allowing for the initialization and updating of schemas, migration generation, schema visualization, and direct synchronization with the database.

Command Reference Table

cycle:ormInit or update cycle schema from database and annotated classes
cycle:orm:migrateGenerate ORM schema migrations.
cycle:orm:renderDisplay ORM schema in your console.
cycle:orm:syncSync Cycle ORM schema with database without intermediate migration (risk operation).

Initializing or Updating ORM Schema


This command initializes or updates the Cycle ORM schema by analyzing the database structure and annotated classes.


php artisan cycle:orm

Generating ORM Schema Migrations


Use this command to generate migrations based on the current ORM schema. It's a crucial step for evolving the database schema in a controlled manner.


php artisan cycle:orm:migrate


  • --r|run - Automatically run generated migration.
  • --s|split - Split migration into multiple files (one per table).


Recording shows migration file generation on existing Domain Entities and their relationships.

Displaying ORM Schema


To visualize the current ORM schema directly in your console, use the cycle:orm:render command. This can help with understanding the structure and relationships defined in your ORM.


php artisan cycle:orm:render


  • --nc|no-color - Display output without colors.
  • --p|php - Display output as PHP code.


Recording shows the visualization of the ORM schema in the console for existing App/Entities/Post entity.

Synchronizing ORM Schema with Database


This command directly synchronizes the Cycle ORM schema with the database. It bypasses the migration system and applies changes directly, which can be risky.


php artisan cycle:orm:sync

Be cautious when using the cycle:orm:sync command, as it directly alters the database schema and can potentially lead to data loss.