开发者

Routing in Symfony

开发者 https://www.devze.com 2023-04-08 23:01 出处:网络
I have two links: http://www.mypage.com/phone/show/id/1 and: http://www.mypage.com/phone/show/id/2 I would like makes links for this

I have two links:

http://www.mypage.com/phone/show/id/1

and:

http://www.mypage.com/phone/show/id/2

I would like makes links for this

http://www.mypage.com/linksone
开发者_Go百科

and

http://www.mypage.com/linkstwo

Is it possible to do that with Symfony routing system?

linksone:
  url: /linksone
  param: { module: phone, action: show}

linkstwo:
  url: /linkstwo
  param: { module: phone, action: show}

Where I can add ID?


I believe this should do it:

linksone:
  url: /linksone
  param: { module: phone, action: show, id: 1}

linkstwo:
  url: /linkstwo
  param: { module: phone, action: show, id: 2}


If you want to do this in Symfony 2+ you need to do the following routing, hopefully someone will find this useful. This is just an example and not using your names/routes.

home_route:
   path: /home
   defaults: { _controller: DemoCoreBundle:StaticPageController:home }

about_route:
   path: /about
   defaults: { _controller: DemoCoreBundle:StaticPageController:about }

team_route:
   path: /team/{member_id}
   defaults: { _controller: DemoCoreBundle:StaticPageController:team, member_id:null }
   requirements:
       member_id: \d+
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号