- Can I use this package to replace Laravel migrations entirely, or should I keep them for app-specific logic?
- This package is best suited for shared or infrastructure schemas (e.g., users, roles) across microservices or multi-DBMS environments. For Laravel-specific logic, retain PHP-based migrations while using YAML schemas for cross-cutting concerns. A hybrid approach minimizes disruption to existing workflows.
- How do I install and configure **ibexa/doctrine-schema** in a Laravel project?
- Install via Composer: `composer require ibexa/doctrine-schema`. Register the package in a Laravel service provider by binding interfaces (e.g., `SchemaImporterInterface`) to implementations. Use `symfony/yaml` or `spatie/fork` for YAML parsing, and configure a schema loader in your `config/services.php`.
- Does this package support Laravel’s native event system, or do I need Symfony’s EventDispatcher?
- The package uses Symfony’s `EventDispatcher`, but you can integrate it with Laravel’s events by wrapping the dispatcher in a Laravel service provider. Alternatively, use `symfony/event-dispatcher` via Composer without full Symfony bundle overhead. Event subscribers can be registered via Laravel’s container.
- Will this work with Laravel 10.x (PHP 8.1–8.2), or do I need PHP 8.3+?
- The package requires PHP 8.3+, but Laravel 10.x supports PHP 8.1–8.2. You may need to pin dependencies (e.g., `doctrine/dbal`, `symfony/*`) to compatible versions or upgrade PHP. Test thoroughly, as some Symfony components may enforce stricter PHP requirements.
- How do I validate YAML schemas before importing them into Doctrine DBAL?
- Use Laravel’s `Validator` facade or custom rules to validate YAML schemas in CI/CD or runtime. For example, check for required keys (`tables`, `columns`) and data types. Alternatively, use Symfony’s `Yaml` component with schema validation libraries like `webmozart/assert` for stricter type enforcement.
- Can I use this package for production databases with large schemas? Are there performance concerns?
- Schema imports/exports should be benchmarked for large databases, as YAML parsing and DBAL operations may introduce latency. Optimize by caching parsed schemas or batching operations. For production, consider running exports/imports during low-traffic periods or via queue workers.
- What are the licensing implications of using this package in a commercial Laravel project?
- The package is dual-licensed under GPL and Ibexa’s Business Use License (BUL). GPL restricts proprietary use unless you comply with its terms. For commercial projects, ensure compliance with Ibexa’s BUL (requires a valid Ibexa DXP subscription) or audit dependencies for conflicts. Consult legal counsel if unsure.
- How do I extend the SchemaBuilder with custom logic (e.g., adding indexes or triggers)?
- Use the event-driven `SchemaBuilder` via `EventSubscriberInterface`. Subscribe to `SchemaBuilderEvents::BUILD_SCHEMA` and inject custom logic (e.g., adding indexes) in the `onBuildSchema` method. Example: Modify the schema object before it’s applied to the database.
- Are there alternatives to this package for YAML-based schema management in Laravel?
- Alternatives include `doctrine/dbal` with custom YAML parsers (e.g., `spatie/fork`) or packages like `laravel-migrations-generator`. However, this package uniquely combines YAML abstraction, cross-DBMS support, and event-driven extensibility. Evaluate based on your need for Symfony integration or hybrid workflows.
- How do I test schema imports/exports in a Laravel test environment?
- Mock the `SchemaImporterInterface` and `SchemaExporterInterface` in PHPUnit tests. Use Laravel’s `DatabaseMigrations` trait to reset the database between tests. Validate YAML output by comparing it to expected schema snapshots or using `assertJsonStringEqualsJsonFile` for exported YAML.