symfony - Symfony2 Route get parameter only if integer -


i got defined routes in routing.yml file

one route is:

profile_user_profile:     path:    /profile/{id}     defaults: { _controller: profilebundle:users:profile }     methods: [get] 

and second is:

profile_accept_connection_proposal:     path:    /profile/acceptproposal     defaults: { _controller:profilebundle:users:acceptconnectionproposal }     methods: [put] 

first route without methods: [get] listen , [put] request , catch second url before route definition. there way define checking parameter if url numeric.

just add requirements parameter accept digits determined route this:

profile_user_profile:     path:    /profile/{id}     defaults: { _controller: profilebundle:users:profile }     methods: [get]     requirements: <--- added parameter         id: \d+ 

for more infos read symfony book routing. there can find more advanced example on how use route parameters.


Comments