0
votes

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

  1. Acme | 1.1 testBundle | 1.11 AcmetestBundle.php | 1.12 Controller | 1.13 testController.php

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

1
what does php app/console route:dump say?meze

1 Answers

2
votes

I think you meant to write prefix instead of pattern:

_test:
   resource: "@AcmetestBundle/Controller/testController.php"
   type:     annotation
   prefix:  /test