Francesco Francesco -4 years ago 417
Twig Question

Symfony inheritance isn't working EasyAdmin bundle

I'm using symfony 3 with EasyAdminBundle

I created a new bundle called AdminBundle child of EasyAdminBundle (to override)

namespace AdminBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class AdminBundle extends Bundle {

public function getParent(){

return 'EasyAdminBundle';


I overrided a method in the controller and it works fine, but when I tried to override a twig template it isn't working...

I created my twig file in

The original is in

How to fix?
(I cleared the caches many times...)

Answer Source

When the EasyAdminBundle:default:index.html.twig is rendered, Symfony actually looks in two different locations for the template:

  1. app/Resources/EasyAdminBundle/views/default/index.html.twig
  2. src/AdminBundle/Resources/views/default/index.html.twig

Your approach is the second option to do this, BUT:

The overriding of resources only works when you refer to resources with the @FOSUserBundle/Resources/config/routing/security.xml method. If you refer to resources without using the @BundleName shortcut, they can't be overridden in this way. [See Doc]

To override the bundle template, just copy the index.html.twig template from the bundle to app/Resources/EasyAdminBundle/views/default/index.html.twig (the app/Resources/EasyAdminBundle directory won't exist, so you'll need to create it). [See Doc]

If you add a template in a new location, you may need to clear your cache (php bin/console cache:clear), even if you are in debug mode.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download