0
votes

I have issue with routing in my Symfony 2 application.

This application contains 2 bundles MainSiteBundle and GalleryBundle I configured routing with prefixes like that:

app/config/routing.yml

honorata_photo_main_site:
resource: "@HonorataPhotoMainSiteBundle/Resources/config/routing.yml"
prefix:   /

honorata_photo_gallery:
resource: "@HonorataPhotoGalleryBundle/Resources/config/routing.yml"
prefix:   /gallery

Routine inside each bundle is not important now because i have issue with this.

When I try to access / route everything works fine (even with sub routes inside bundle) When I try to access /gallery route it shows me error like:

No route found for "GET ery"
404 Not Found - NotFoundHttpException
1 linked Exception: ResourceNotFoundException ยป

Why Symfony 2 router cuts first 3 letters after / ?

2

2 Answers

0
votes

I would guess that inside "@HonorataPhotoMainSiteBundle/Resources/config/routing.yml" you have some more general route defined.

Try reversing the order of definition:

honorata_photo_gallery:
    resource: "@HonorataPhotoGalleryBundle/Resources/config/routing.yml"
    prefix:   /gallery

honorata_photo_main_site:
    resource: "@HonorataPhotoMainSiteBundle/Resources/config/routing.yml"
    prefix:   /
0
votes

Subject resolved and closed !

Problem was that /gallery path already exist in MainSiteBundle I realised that using php app/console route:debug and after deeper analysis :)

Next time I will make routing log to prevent that in the future.