ns/ace-sonata-doctrine-orm-admin-bundle
A Symfony bundle that integrates Sonata Admin with Doctrine ORM, providing admin interfaces for managing Doctrine-backed entities. It connects ORM mappings and persistence to Sonata’s admin framework to simplify CRUD administration in Symfony applications.
This bundle is a thin Twig-template override layer for Sonata Admin’s Doctrine ORM admin, swapping Sonata’s default CRUD/layout markup for the “Ace” admin theme. There is effectively no PHP API surface to learn — your integration work is almost entirely in template config and Twig.
Minimal steps:
Install alongside a working Sonata Admin setup:
composer require ns/ace-sonata-doctrine-orm-admin-bundle
You must already have sonata-project/admin-bundle and sonata-project/doctrine-orm-admin-bundle installed and configured — this package depends on them and will not bootstrap Sonata for you.
Register the bundle in config/bundles.php (Symfony 4+) or AppKernel::registerBundles():
return [
// ... Sonata bundles first
Ns\AceSonataDoctrineORMAdminBundle\NsAceSonataDoctrineORMAdminBundle::class => ['all' => true],
];
Point Sonata at the Ace templates in config/packages/sonata_admin.yaml:
sonata_admin:
templates:
layout: '@NsAceSonataDoctrineORMAdminBundle/standard_layout.html.twig'
edit: '@NsAceSonataDoctrineORMAdminBundle/CRUD/edit.html.twig'
list: '@NsAceSonataDoctrineORMAdminBundle/CRUD/list.html.twig'
show: '@NsAceSonataDoctrineORMAdminBundle/CRUD/show.html.twig'
Clear cache and open any existing admin. First use case: confirm an existing CRUD screen renders with the Ace layout before you change anything else.
Where to look first: vendor/ns/ace-sonata-doctrine-orm-admin-bundle/Resources/views/ (or templates/ in newer layouts). That directory is the package — the Twig files and the blocks they define are the contract you’ll be extending.
Global theme, per-admin override. Use sonata_admin.templates for the site-wide default, then override per admin class via $admin->setTemplate('edit', '...') or the getTemplate() method when one admin needs different markup. This lets you apply the Ace theme broadly but keep a bespoke screen for one entity.
Extend, don’t replace. The intended pattern is to {% extends '@NsAceSonataDoctrineORMAdminBundle/CRUD/edit.html.twig' %} in your own templates and override individual blocks (typically form, form_actions, tabs, list_footer). Copying a vendor template into your app and editing it locally will silently drift from upstream markup and is the main source of “why did my field rendering change” bugs.
Form theming. If Ace markup affects form rendering, register the bundle’s form theme in twig.yaml (form_themes: ['@NsAceSonataDoctrineORMAdminBundle/Form/...']) so horizontal/vertical field layouts are consistent across CRUD and custom forms.
Per-admin customization workflow. The pragmatic loop is: render the screen, view-source or use Symfony’s Twig profiler, find the block producing the markup, then override that one block in an admin-specific template. Keep overrides shallow — one or two blocks per template.
Integration with your own assets. Ace’s CSS/JS typically needs to be wired into standard_layout.html.twig’s asset blocks or into sonata_admin.templates.layout. If you also run Webpack Encore, override the asset blocks rather than the whole layout so you keep Sonata’s admin JS wiring intact.
Config-driven customization. Prefer Sonata’s own config knobs (sonata_admin.options, dashboard groups, title_logo) over editing layout templates — they survive package upgrades.
composer.json and verify compatibility against your installed Sonata Admin major version before committing to it; Sonata’s template block names and Twig inheritance change between majors.assets:install step if the templates reference bundles/nsace... paths.bin/console cache:clear or set twig.cache: false in dev locally.{% dump %} inside an overridden block to inspect available variables (admin, form, object, action) — the bundle doesn’t document its template context.How can I help you explore Laravel packages today?