php - URL alias or replace with symfony2


I have the application which generates urls like this


My routing.yml is

    pattern:  /show/{userId}
    defaults: { _controller: AcmeTopBundle:Default:showUser}   

12 or 14 is id used in database.

id| name | position
12| james| pitcher 
14| nick | short
15| ian  | catcher

Now,what I would like to make alias for this urls



I have googled with keywords like 'alias' 'url exchange' or something, howevere can't find good example or bundle.

Could you help me?




You can actually have multiple routes pointing to the same bundle:controller:action.

For example if you want to use

pattern:  /{name}
defaults: { _controller: AcmeTopBundle:Default:showUser}  

The only thing you have to be aware of is that in the controller action you need to either pass the Request object to get either the param "name" or "userId", Alternatively you could name the param the same and manage it by hand (so to speak).

Could you post the controller action here also?

People are also looking for solutions to the problem: php - How to delete this items in laravel5 (array)?


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.