Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7603779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:44:26+00:00 2026-05-30T23:44:26+00:00

I need to have dynamic routes with symfony 2 where a slug parameter is

  • 0

I need to have dynamic routes with symfony 2 where a slug parameter is added to the url and is related to a page in the database. Each page has a own slug and its content stored in the database. I read the article Advanced Routing but it’s for the old version of symfony. For the new version it seems that ParamConverter does a similar job. Is this the correct way to implement a doctrine-based routing or should I write a real custom router class?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T23:44:28+00:00Added an answer on May 30, 2026 at 11:44 pm

    I would use a ParamConverter, yes. The default DoctrineParamConverter that ships with the FrameworkExtraBundle can handle most simple cases — that is, it knows how to look up a typehinted object by a field with the same name as the route placeholder:

    // routing.yml
    foo_route:
        pattern: /{slug}/
        defaults: { _controller: FooVendorBundle:Foo:view }
    
    // FooVendorBundle/Controller/FooController.php
    public function view(FooEntity $foo)
    {
        // $foo will be an instance of FooEntity
    }
    

    Normally, in a controller’s argument list, you’d have a $slug variable that would be populated from the contents of {slug} captured by the route. However, with the ParamConverter, it recognizes that you’re requesting a FooEntity class, and will try to find that entity by the captured slug value and populate the $foo variable with that entity.

    The default ParamConverter is, of course, limited to only being able to look up properties that actually exist on the entity: if FooEntity does not have a field named slug, the lookup will fail and an exception will be thrown. Like I said, this will handle a majority of basic use cases. If you need more in-depth conversion of request parameters, you could always write your own.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to have a dynamic URL preferably from a Test Class. Can any
I have added some dynamic textboxes upon a button click. I need the values
i have create 7 dynamic buttons in a scroll box. Each row need to
I have a dynamic SQL statement I've created in a stored procedure. I need
I have a set of 'dynamic data' that I need to bind to the
I need to used dynamic order query in mysql and i have successfully achieved
I need to build a dynamic linq query with or operators. I have seen
I have set up my coldfusion application to have dynamic urls on the page,
I'm developping an android application. For that I need to have a dynamic tableView.
I am building a website where I need to have dynamic categories like ebay

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.