Weave 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

Sonata Gedmo Doctrine Extensions Bundle Laravel Package

presta/sonata-gedmo-doctrine-extensions-bundle

A Symfony bundle that integrates Gedmo Doctrine extensions with Sonata Admin, adding ready-made admin extensions and form types for timestampable, sluggable, sortable, tree, translatable, and soft-delete behavior—so you can manage Gedmo-powered entities directly from your Sonata panels with minimal...

View on GitHub
Deep Wiki
Context7

Getting Started

Prerequisites. This bundle is archived and targets the Symfony 2/3 + Sonata Admin 3.x era. Before installing, confirm your stack matches: PHP 5.6–7.x, sonata-project/admin-bundle (3.x), doctrine/doctrine-bundle, and gedmo/doctrine-extensions (2.x). Do not attempt to drop it into a Symfony 5/6 project without expecting breakage.

Install.

composer require presta/sonata-gedmo-doctrine-extensions-bundle

Register the bundle (legacy AppKernel, or config/bundles.php if your project is Flex-based):

// app/AppKernel.php
new Presta\Sonata\GedmoDoctrineExtensionsBundle\PrestaSonataGedmoDoctrineExtensionsBundle(),

Where to look first. Open the bundle's DependencyInjection/Configuration.php and Resources/config/ — that is where the supported Gedmo listeners and any Sonata admin extensions/templates are wired. Then check the README examples, which are the only reliable documentation for the archived version. Treat the source as the spec.

Minimum viable config. Enable only the Gedmo extensions you actually use; the bundle integrates with the listeners that are active:

# config.yml
stof_doctrine_extensions:
    orm:
        default:
            timestampable: true
            blameable: true
            sluggable: true
            tree: true
            softdeleteable: true
            translatable: true

presta_sonata_gedmo_doctrine_extensions:
    # enable the admin integrations you need (tree, translatable, softdelete, ...)

First use case. The fastest payoff is making a Gedmo-managed createdAt / updatedAt / slug field appear read-only in a Sonata list and detail view instead of being rendered as an editable form widget. Annotate the entity with Gedmo mappings, then in your AbstractAdmin subclass place the fields in configureListFields()/configureShowFields() and keep them out of configureFormFields().

Implementation Patterns

Read-only managed fields. Gedmo writes createdAt, updatedAt, slug, and createdBy/updatedBy itself. The standard pattern is to expose them in list/show and exclude them from the form:

protected function configureListFields(ListMapper $list)
{
    $list
        ->addIdentifier('title')
        ->add('slug')
        ->add('createdAt', 'datetime')
        ->add('updatedAt', 'datetime');
}

protected function configureFormFields(FormMapper $form)
{
    $form->add('title'); // no slug, no timestamps
}

Blameable wiring. Blameable needs a user resolver. Register a Gedmo\Blameable\Mapping\Driver\...-compatible listener with a callable/security-token provider, or supply the bundle's configured user provider. Verify the createdBy column is nullable so CLI/import fixtures don't fail.

Tree admin. For Tree entities, use the bundle's tree-aware admin/controller conventions: enable the tree listener, register the entity as a tree repository (@Gedmo\Tree(type="nested") or closure), and expose move up/down/root actions in the admin. The datagrid must sort by the tree hierarchy columns (lft/rgt/root for nested set), not by arbitrary fields, or reordering actions will appear to do nothing.

Translatable admin. Gedmo Translatable stores one row per locale in the translation table. In Sonata this means either (a) a locale switcher that reloads the form with the current locale set on the Gedmo listener, or (b) a per-locale embedded form. The bundle's translatable integration handles the listener's locale; you handle the UI (a locale selector in the admin header is the common pattern). Keep the translation entity fields aligned across locales or forms will silently save partial data.

SoftDeleteable. Enable the SoftDeleteableFilter, then expose delete/restore. The admin's delete action removes the entity from view after the soft delete; add a custom restore action (or a batch action) that calls $entityManager->getFilters()->disable('softdeleteable') and clears deletedAt. Lists should hide soft-deleted rows by default, with an optional "show deleted" toggle.

Loggable / versioning. If enabled, Loggable writes to a log table via a LoggableListener. Surface history through a custom admin tab that queries the log entries for the object, or skip it if the bundle version doesn't include a ready-made integration.

Admin extensions as the extension point. The idiomatic Sonata way to add Gedmo behavior across many admins is a AbstractAdminExtension (e.g., a TimestampableAdminExtension that auto-adds createdAt/updatedAt to every list). Register it as a service tagged sonata.admin.extension and target it with sonata.admin.extension.target if you only want it on some admins.

Gotchas and Tips

  • Archived = frozen dependency graph. The bundle pins old Sonata/Doctrine versions. Composer will likely resolve to gedmo/doctrine-extensions 2.x and Sonata 3.x. In modern projects, prefer using gedmo/doctrine-extensions directly plus small custom Sonata admin extensions — this bundle adds little you can't replicate in a few services.
  • Listener registration order matters. Gedmo's Timestampable and Sluggable must run before persistence; Blameable needs the security token populated (breaks in CLI/workers). If createdAt is null after insert, check that the event subscriber is registered for the correct entity manager.
  • Annotations vs attributes. Old Gedmo only understands annotations/XML/YAML mappings. PHP 8 attributes are not supported by the pinned version — mixing them silently results in unmanaged fields.
  • Soft-delete filter leakage. Disabling softdeleteable to restore an entity and forgetting to re-enable it means the rest of the request shows deleted rows. Wrap in try/finally.
  • Tree queries vs datagrid. Sonata's ProxyQuery and Gedmo's tree repository don't always compose; sorting or paginating a nested-set list can produce wrong hierarchy order. Use the tree-specific sort configuration.
  • Translatable locale context. The Gedmo TranslatableListener holds the locale globally per request. In long-running workers or when switching locales in admin, reset it explicitly or you'll save to the wrong translation row.
  • Slug collisions. Sluggable on a unique column can throw on duplicates; either configure a unique suffix handler or make the column non-unique.
  • Debugging. Use bin/console doctrine:mapping:info and the Symfony profiler's Doctrine panel to confirm the listeners are attached. doctrine.event_subscriber tags are the quickest check that the bundle's wiring is active.
  • Templates and assets. The bundle ships (minimal) admin templates for its integrations; if you override them, Symfony's bundle inheritance/Resources/views override path is version-sensitive. Copy into your app's templates/bundles/... only on Symfony 4+.
  • Migration path. Since it's unmaintained with essentially no dependents, budget for replacing it: keep Gedmo listeners configured directly, move any admin behavior you rely on into your own AbstractAdminExtension services, and drop the bundle. That keeps your Gedmo features intact when you upgrade Sonata.
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.
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource