I'm learning Symfony 2 but I have some problems. Using a tutorial, I created this route in the routing.yml
inside bundle:
acme_demo_homepage:
path: /hello/{name}
defaults: { _controller: AcmeDemoBundle:Default:index }
random:
path: /random/{limit}
defaults: { _controller: AcmeDemoBundle:Random:index }
and Eclipse shows me an error at line where defaults
is declared and tells me that :
is unexpected.
I have created the controller:
<?php
namespace Acme\DemoBundle\Controller;
use Symfony\Component\HttpFoundation\Response;
class RandomController
{
public function indexAction($limit)
{
return new Response('<html><body>Number: '.rand(1, $limit).'</body></html>');
}
}
but when I try to execute localhost/app_dev.php/random/10
this error appears:
The routing file "C:\xampp\htdocs\progetti\Symfony\src\Acme\DemoBundle/Resources/config/routing.yml" contains unsupported keys for "acme_demo_homepage": "random". Expected one of: "resource", "type", "prefix", "pattern", "path", "host", "schemes", "methods", "defaults", "requirements", "options", "condition".
routing.yml
exactly like one you posted? You need to havepath
anddefaults
keys intended using spaces – Tomasz Madeyski