arxy/entity-translations-bundle
title, description) rather than static strings. This aligns well with Symfony/Doctrine-based architectures where entities are the primary data model.Translatable, Translation, Language) without tightly coupling to Symfony’s translation system, making it adaptable to standalone PHP/Laravel (via Doctrine ORM) or other frameworks.Translator, Form, and Twig components heavily (e.g., TranslationsType, translate filter). Laravel alternatives (e.g., spatie/laravel-translatable, laravel-localization) would need bridging.doctrine/orm or laravel-doctrine), integration is straightforward. For native Eloquent, a custom adapter layer would be required to map Doctrine-specific features (e.g., postPersist events) to Laravel’s lifecycle.Translator, TranslationLoader) would need to be rewired using Laravel’s container or a bridge like symfony/dependency-injection.Form component is absent in Laravel. The TranslationsType form would require a custom Laravel Form Request or integration with a package like laravelcollective/html (limited support).news_translations). Laravel’s spatie/laravel-translatable uses a JSON column or separate tables, which may require schema migrations.Translator service may trigger multiple queries when fetching translations for entities. Laravel’s Eloquent or Doctrine’s DDC (Data Mapper) could optimize this with eager loading.EventDispatcher, PropertyAccessor, etc., may break in Laravel.spatie/laravel-translatable (simpler, Eloquent-focused) or laravel-localization (URL/locale routing).gedmo/doctrine-extensions (mature, but heavier).Why Laravel?
spatie/laravel-translatable)?Entity Complexity:
title, description) or entity-level (e.g., entire Product in multiple languages)?Form Requirements:
TranslationsType form integration adds significant complexity.NotBlank for English) critical?Performance Trade-offs:
Maintenance:
PropertyAccess, EventDispatcher) that can be replaced in Laravel?| Component | Symfony Fit | Laravel Adaptation | Risk |
|---|---|---|---|
| Doctrine ORM | Native | Requires doctrine/orm package |
Medium (adds ~50MB to vendor) |
| Service Container | Symfony DI | Bridge via symfony/dependency-injection or custom container |
High (complexity) |
| Forms | Symfony Form |
Replace with Laravel FormRequest or spatie/laravel-forms |
High (limited feature parity) |
| Twig Integration | Native | Use laravel-blade-directives or custom Blade directives |
Medium (manual mapping) |
| Event System | Symfony EventDispatcher |
Use Laravel’s Events or doctrine/events |
Low (if using Doctrine) |
| Translation Service | Symfony Translator |
Use Laravel’s translator or spatie/laravel-translation |
Low |
symfony/property-access with Laravel’s Illuminate\Support\Facades\Facade or php-di/php-di.symfony/event-dispatcher with Laravel’s Events or Doctrine’s EventManager.doctrine/orm and configure Laravel’s service provider.postPersist) to Laravel’s ModelObserver.config/app.php or a custom provider:
$container->bind(\Arxy\EntityTranslationsBundle\Translator::class, function ($container) {
return new \Arxy\EntityTranslationsBundle\Translator(
$container->make(\Doctrine\ORM\EntityManager::class),
$container->make(\Symfony\Component\PropertyAccess\PropertyAccess::class)
);
});
TranslationsType; build a custom Laravel Form Request or use a package like laravelcollective/html (limited).Blade::directive('translate', function ($expr) {
return "<?php echo app('translator')->get($entity->{$expr[0]}, ['locale' => auth()->getLocale()]); ?>";
});
laravel-graphql) or REST API to Laravel frontend.spatie/laravel-translatable for JSON-based translations.laravelcollective/html or spatie/laravel-forms.laravel-blade-directives.postPersist events).PropertyAccess: Replaceable with Laravel’s app()->make() or php-di.EventDispatcher: Replaceable with Laravel’s Events.Twig: Non-critical if using Blade.Product, Article) to testHow can I help you explore Laravel packages today?