I'm creating a reusable bundle for my projects which depends heavily on overrides. Weirdly at some point my routing got ignored and I can't get it to work.
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"
]
},
...
But I still get a NotFoundHttpException - No route found for "GET /"
Am I missing some special configuration for bundles?
Update: obviously it has something to do with parenting the bundle. When I remove the getParent() function everything works as expected again - however I need this to override the bundle.
namespace AppBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class AppBundle extends Bundle
{
public function getParent()
{
return 'MyBundle';
}
}