I created a bundle backend/main/:
my app/routing.yml
backendmain:
resource: "@backendmainBundle/Resources/config/routing.yml"
prefix: /main
my backend/Bundle/mainBundle/config/routing.yml:
backendmain_homepage:
pattern: /hello/{name}
defaults: { _controller: backendmainBundle:Default:index }
my backend/Bundle/mainBundle/DefaultController.php:
namespace backend\Bundle\mainBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class DefaultController extends Controller
{
public function indexAction($name)
{
return $this->render('backendmainBundle:Default:index.html.twig', array('name' => $name));
}
public function testAction($name)
{
return $this->render('backendmainBundle:Default:test.html.twig', array());
}
}
How can I call the action test in my browser?
Sorry, but was Fabien on drugs, when he created Symfony2? Symfony 1.4 was so freaking easy!
There isn’t any match in your routes definition for the test action. The only route you added is for the index action. So you need to add something like,
In your
backend/Bundle/mainBundle/config/routing.ymlfile so that you can make a call to your test action.Update:
Using annotations
app/config/routing.yml
DefaultController.php