I understand that symfony recommends to use the default AppBundle (as stated in this page http://symfony.com/doc/current/best_practices/creating-the-project.html), however because my project is comprised of a number of stand-alone apps, I would like to separate them into their own bundles.
I am trying to generate a bundle with help of the symfony2 console generate:bundle command. Directory structures seem to be all in place, however I constantly get an error message that the route is not defined, although I have defined it.
The exception I get:
request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /hello/somename"" at C:\wamp\www\symfony\test\app\cache\prod\classes.php line 2480 {"exception":"[object] (Symfony\Component\HttpKernel\Exception\NotFoundHttpException(code: 0): No route found for \"GET /hello/somename\" at C:\wamp\www\symfony\test\app\cache\prod\classes.php:2480, Symfony\Component\Routing\Exception\ResourceNotFoundException(code: 0): at C:\wamp\www\symfony\test\app\cache\prod\appProdUrlMatcher.php:35)"} []
Here is the setup:
routing.yml:
my:
resource: "@MyBundle/Resources/config/routing.php"
prefix: /
app:
resource: "@AppBundle/Controller/"
type: annotation
routing.php:
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\Route;
$collection = new RouteCollection();
$collection->add('my_homepage', new Route('/hello/{name}', array(
'_controller' => 'MyBundle:Default:index',
)));
return $collection;
MyBundle/Controller/DefaultController.php
namespace MyBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class DefaultController extends Controller
{
public function indexAction($name)
{
return $this->render('MyBundle:Default:index.html.twig', array('name' => $name));
}
}
The bundle is also properly registered in the AppKernel class.
As I understand it, calling mydomain.local/hello/somename should do the trick, but it won't work.
P.S. I Also tried the annotation method, but it wont work either (I get the same result)
P.S. 2 I know this is a much asked question, but non of the answers I have found so far seems to be helping me with the issue as is.
P.S. 3 the default AppBundle works properly, using similar settings (but annotations instead)