自定义可重用包的 Symfony 3 路由被忽略

Symfony 3 Routing for custom reusable Bundle ignored

我正在为我的项目创建一个可重用的包,它在很大程度上依赖于覆盖。奇怪的是,在某些时候我的路由被忽略了,我无法让它工作。

Note: AppBundle extends MyBundle

routing.yml

my:
    resource: '@MyBundle/Controller/'
    type: annotation
app:
    resource: '@AppBundle/Controller/'
    type: annotation

src/MyBundle/Controller/IndexController.php

<?php

namespace MyBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;

class IndexController extends Controller
{
    /**
     * Index
     *
     * @Route("/", name="index")
     * @Method("GET")
     */
    public function indexAction()
    {
        return $this->render('index.html.twig');
    }

}

composer.json

...
"autoload": {
    "psr-4": {
        "AppBundle\": "src/AppBundle",
        "MyBundle\": "src/MyBundle"
    },
    "classmap": [
        "app/AppKernel.php",
        "app/AppCache.php"
    ]
},
...

但我仍然收到 NotFoundHttpException - 找不到 "GET /"

的路由

我是否遗漏了一些特殊的捆绑配置?

更新:显然它与育儿包有关。当我删除 getParent() 函数时,一切再次按预期工作 - 但是我需要它来覆盖包。

namespace AppBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class AppBundle extends Bundle
{
    public function getParent()
    {
        return 'MyBundle';
    }

}

尝试“../../src/MyBundle/Controller”和“../../src/AppBundle/Controller”

known issue, but "bundle inheritance is now deprecated and will be removed in Symfony 4”。