Reputation: 6269
I have created a route named "test" but symfony cannot find it.
Routing_dev.php
_test:
resource: "@AcmetestBundle/Controller/testController.php"
type: annotation
pattern: /test
Added this line to AppKernel.php
$bundles[] = new Acme\testBundle\AcmetestBundle();
Created a dir described below
AcmetestBundle.php
namespace Acme\testBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class AcmetestBundle extends Bundle
{
public function __construct(){
var_dump("initializing ".__DIR__);
}
}
testController.php
namespace Acme\testBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Acme\DemoBundle\Form\ContactType;
// these import the "@Route" and "@Template" annotations
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
class testController extends Controller
{
/**
* @Route("/", name="_demo")
* @Template()
*/
public function indexAction()
{ var_dump(11);
return array("");
}
}
Browser logs :
No route found for "GET /test" 404 Not Found - NotFoundHttpException 1 linked Exception: ResourceNotFoundException »
Symfony\Component\HttpKernel\Exception\NotFoundHttpException: No route found for "GET /test" (uncaught exception) at C:\xampp\htdocs\Symfony\app\cache\dev\classes.php line 4560
Upvotes: 0
Views: 4902
Reputation: 15097
I think you meant to write prefix instead of pattern:
_test:
resource: "@AcmetestBundle/Controller/testController.php"
type: annotation
prefix: /test
Upvotes: 2