Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Schema Builder

Schema Builder Laravel Package

cycle/schema-builder

Fluent PHP schema builder for Cycle ORM. Define tables, columns, indexes and relations in code, then generate/compile database schema changes for migrations and tooling. Helps keep your domain models and database structure in sync.

View on GitHub
Deep Wiki
Context7

Declarative schema generation for Cycle ORM

Frequently asked questions about Schema Builder
Can Cycle Schema Builder replace Laravel migrations in a Cycle ORM project?
Yes, it’s designed to replace traditional migrations. Define tables, columns, and relations declaratively in PHP, then compile them into SQL-compatible schema changes. This aligns with Cycle ORM’s philosophy and reduces manual SQL maintenance.
How do I install Cycle Schema Builder in a Laravel project using Cycle ORM?
Run `composer require cycle/schema-builder` and configure it in your Cycle ORM setup. The package integrates directly with Cycle’s Registry and Compiler, so no Laravel-specific dependencies are required beyond Cycle ORM itself.
Does this package support Laravel’s Eloquent or Doctrine ORM?
No, it’s tightly coupled with Cycle ORM. If you’re using Eloquent or Doctrine, you’d need to refactor your ORM layer to Cycle ORM first, which may not be worth the effort for existing projects.
What Laravel versions and PHP versions does Cycle Schema Builder support?
The package requires **PHP 8.1+** and works with Laravel projects using **Cycle ORM v3+**. It’s not a Laravel-specific package, so it doesn’t enforce Laravel version constraints—just ensure your Cycle ORM setup is compatible.
How do I handle complex relations like STI (Single Table Inheritance) or composite keys?
Cycle Schema Builder fully supports STI, JTI (Joined Table Inheritance), composite keys, and generated fields. Define them in your entity definitions using the fluent API, and the compiler will generate the appropriate SQL schema.
Can I use this for production deployments? How does it handle schema migrations?
Yes, it’s production-ready. Use the `PrintChanges` generator to preview schema diffs before deployment, and integrate it into your CI/CD pipeline. For rollbacks, combine it with Cycle Migrations or implement custom logic.
What if my database has legacy schemas or unsupported SQL features (e.g., triggers)?
Cycle Schema Builder focuses on ORM-supported features. For legacy schemas, manually define unsupported parts in SQL migrations alongside the declarative definitions. Complex SQL (e.g., triggers) may require hybrid approaches.
How does performance compare to Laravel’s Schema Builder or Doctrine Migrations?
Performance depends on your use case. Cycle Schema Builder compiles schemas dynamically, which may add slight overhead during cold starts (e.g., serverless). Benchmark against your existing migrations, but it’s optimized for Cycle ORM’s efficiency.
Is there a way to test schema changes before applying them to production?
Yes, use the `PrintChanges` generator to output SQL diffs without executing them. You can also mock the compiler in unit tests to validate schema definitions before deployment.
What are the alternatives if I don’t want to use Cycle ORM or this package?
For Laravel, stick with **Laravel Migrations** or **Doctrine Migrations** if using Eloquent. For Cycle ORM, you can manually write SQL migrations, but Schema Builder provides a more maintainable, declarative alternative.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi