As the title say explecitly, I don't manage to get some specific route I recently added. My symfony version : 2.8.18. So here are the details :
Route I try to match : - /platform/cat - /platform/cat/{id}
File - app/config/routing.yml :
gb_platform:
resource: "@GBPlatformBundle/Resources/config/routing.yml"
prefix: /platform
File - GB\PlatformBundle\Resources\configouting.yml :
gb_platform_home_:
path : /
defaults: { _controller: GBPlatformBundle:Advert:index }
gb_platform_home:
path : /{page}
defaults:
_controller : GBPlatformBundle:Advert:index
page: 1
requirements:
page: \d*
gb_platform_view:
path : /advert/{id}
defaults: { _controller : GBPlatformBundle:Advert:view }
requirements:
id: \d+
gb_platform_add:
path : /add
defaults: { _controller : GBPlatformBundle:Advert:add }
gb_platform_edit:
path : /edit/{id}
defaults: { _controller : GBPlatformBundle:Advert:edit }
requirements:
id: \d+
gb_platform_delete:
path : /delete/{id}
defaults: { _controller : GBPlatformBundle:Advert:delete }
requirements:
id: \d+
gb_platform_cat:
path : /cat
defaults: { _controller : GBPlatformBundle:Category:index }
gb_platform_cat_view:
path : /cat/{id}
defaults: { _controller : GBPlatformBundle:Category:view }
requirements:
id: \d+
File - GB\PlatformBundle\Resources\controller\CategoryController.php :
<?php
namespace GB\PlatformBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpFoundation\Response;
use GB\PlatformBundle\Entity\Advert;
use GB\PlatformBundle\Entity\Category;
class CategoryController extends Controller
{
public function indexAction(Request $request)
{
}
public function viewAction($id)
{
$em = $this->getDoctrine()->getManager();
$catRepo = $em
->getRepository('GBPlatformBundle:Category');
$cat = $catRepo
->find($id);
if($cat === null)
{
throw new NotFoundHttpException("L'annonce d'id ".$id." n'existe pas.");
}
return $this->render('GBPlatformBundle:Category:view.html.twig', array(
'category' => $cat,
));
}
}
At the origin, the routing.yml of the bundle was invalid. Once it's fixed, I try to get the both command :
php app/console debug:router
php app/console debug:router gb_platform_cat
php app/console debug:router gb_platform_add
Each command were successfull and I saw no difference between /cat and /add while one match and the other don't. I tried also many times to clear cache with :
php app/console cache:clear --env prod
Still don't work. I'm confused ... The error is basic : No route found for "GET /platform/cat/7
