brokalia/doctrine-entity-generator
laravel-doctrine/orm), this introduces dependency friction unless the application already uses Symfony components.MyDomainEntityId) but lacks explicit configuration for custom mapping logic (e.g., nested value objects, complex types). This may require manual overrides or post-generation adjustments.symfony/console package or a custom wrapper.laravel-doctrine/orm package provides Doctrine integration, so the ORM layer is already supported.laravel-doctrine/console (if available).// app/Console/Commands/GenerateDoctrineEntity.php
use Brokalia\DoctrineEntityGenerator\Generator\Generator;
use Symfony\Component\Console\Command\Command;
class GenerateDoctrineEntity extends Command {
protected function execute(InputInterface $input, OutputInterface $output) {
$generator = new Generator();
$generator->generate($input->getArgument('entity'));
}
}
twig/twig) would be needed for template rendering.incrementing to IDs).Why Doctrine Over Eloquent?
Template Flexibility
snake_case vs. camelCase)?#[Attribute]) be handled?Migration Path
migrate system) interact with Doctrine’s schema updates?Performance Impact
Testing Strategy
create) need to be rewritten for Doctrine?| Component | Laravel Native | Required Package | Notes |
|---|---|---|---|
| Console | ✅ Artisan | symfony/console |
Minimal overhead; can wrap existing CLI. |
| Doctrine ORM | ❌ No | laravel-doctrine/orm |
Requires configuration (DSN, caching). |
| Templates | ❌ No | twig/twig |
Or use Blade with custom logic. |
| Dependency Injection | ❌ No | Symfony’s DI or Laravel’s | Potential container conflicts. |
Phase 1: Proof of Concept (PoC)
brokalia/doctrine-entity-generator and laravel-doctrine/orm.php artisan doctrine:schema:update --dump-sql to preview migrations.Phase 2: Hybrid Architecture
.env database settings.config/doctrine.php:
return [
'dbal' => [
'driver' => 'pdo_mysql',
'url' => env('DB_CONNECTION'),
],
];
Phase 3: Full Adoption
EntityManager.@ORM\Id), but Laravel supports PHP 8 attributes (#[ORM\Id]).doctrine/annotations for backward compatibility or configure the generator to output attributes.// app/Providers/AppServiceProvider.php
public function boot() {
$this->commands([
\App\Console\Commands\GenerateDoctrineEntity::class,
]);
}
prePersist) may need Laravel event listeners for side effects (e.g., logging, queues).Prerequisites:
laravel-doctrine/orm and configure Doctrine.symfony/console and twig/twig (if using templates).php artisan doctrine:query:sql "SELECT 1".Generator Setup:
Persistence Layer:
CI/CD Integration:
php artisan doctrine:schema:validate to deployment checks.How can I help you explore Laravel packages today?