ibexa/doctrine-schema
Symfony bundle that abstracts cross-DBMS schema import/export. Defines a custom YAML schema format, imports YAML into Doctrine DBAL Schema, exports Schema back to YAML, and provides an event-driven SchemaBuilder extension point via subscribers.
SchemaBuilder leverages Symfony’s event system, enabling custom logic injection (e.g., pre/post-schema build hooks). This fits Laravel’s service container and event ecosystem (via Illuminate\Events or Symfony\Component\EventDispatcher).SchemaImporterInterface, SchemaExporterInterface) can be adapted via Laravel’s service providers or facade wrappers.doctrine/dbal). This package extends DBAL’s schema capabilities without replacing existing workflows.spatie/fork). Schema validation can be added via Laravel’s Illuminate\Validation or custom rules.SchemaBuilder, SchemaImporter).doctrine/dbal, symfony/*).EventDispatcher, Yaml). Laravel’s minimalist approach may lead to conflicts or unnecessary bloat if not scoped properly.EventDispatcher be used? How will event subscribers be registered?\Doctrine\DBAL\Schema) integrates seamlessly with Laravel’s existing DBAL usage (e.g., SchemaManager, Connection).illuminate/support or symfony/event-dispatcher (via Composer) for event handling. Avoid full Symfony bundles to minimize overhead.symfony/yaml (lightweight) or spatie/fork (Laravel-native) for parsing YAML schemas. Validate schemas with Laravel’s Validator or custom rules.ibexa/doctrine-schema:^5.0).SchemaBuilder, SchemaImporter) to concrete implementations.users, roles) while keeping Laravel migrations for app-specific tables.# config/db/schema.yaml
tables:
users:
columns:
id: { type: integer, primary: true }
email: { type: string, length: 255 }
BootstrapSchema service:
$schemaBuilder = app(SchemaBuilder::class);
$schema = $schemaBuilder->buildSchema();
$connection->getSchemaManager()->createSchema($schema);
SchemaValidator to enforce constraints (e.g., no duplicate column names) during deployment.doctrine/dbal (v3.x+). No conflicts expected.EventDispatcher, Yaml) to avoid Laravel-Symfony framework collisions.Event system via a custom listener:
Event::listen(SchemaBuilderEvents::BUILD_SCHEMA, function (SchemaBuilderEvent $event) {
// Custom logic
});
doctrine/dbal/symfony/* to compatible versions.SchemaExporter.schema/v1/users.yaml) to support rollbacks. Use Laravel’s Artisan commands to manage versions:
php artisan schema:export --version=v1
ibexa/doctrine-schema for updates and align with Laravel’s release cycle. Pin versions in composer.json to avoid surprises.SchemaBuilder via event subscribers for project-specific logic (e.g., adding indexes, triggers). Document these extensions for onboarding.Schema object to debug:
$sql = $schema->toSql($connection->getDatabasePlatform());
SchemaBuilder to log events (e.g., schema load time, errors) using Laravel’s Log facade.SchemaBuilder events to synchronize schema updates across deployments.| Failure Scenario | Mitigation Strategy |
|---|---|
| Invalid YAML syntax | Use symfony/yaml with strict parsing or Laravel’s Validator. |
| Schema import conflicts | Implement pre-flight checks (e.g., compare current DB schema with YAML). |
| DBMS-specific syntax errors | Test schemas on all target DBMS early. Use DBAL’s DatabasePlatform for platform-aware SQL. |
| Event subscriber failures | Wrap event logic in try-catch blocks and log errors. |
| Dependency version conflicts | Use Composer’s conflict-resolution or isolate Symfony components in a separate package. |
schema-template.yaml starter file.# .github/workflows/schema-check.yml
jobs:
schema-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: composer install
- run: php artisan schema
How can I help you explore Laravel packages today?