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 6206387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:26:31+00:00 2026-05-24T05:26:31+00:00

I wanna make a simple URL to Controller mapping very much like what Symfony2

  • 0

I wanna make a simple URL to Controller mapping very much like what Symfony2 does. But that’s all I want from Symfony2, rest of it is just too much for me.

For those who don’t know what Symfony2 does:

blog_home:
    pattern:   /blog
    defaults:  { _controller: BlogBundle:Blog:index }

blog_show:
    pattern:   /blog/{slug}
    defaults:  { _controller: BlogBundle:Blog:show }

in a YAML config file.

YAML doesn’t matter to me at all. I just wanna achieve the same functionality. To be able to map custom URLs to controller functions.

Maybe an open source mapping class or routing framework? Maybe some tutorials? Ideas to make my own? Any suggestions would be helpful.

I should mention I’m no PHP whiz, I know just enough or maybe a little less than enough. Which is why I don’t wanna get into a full featured framework.

  • 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-24T05:26:31+00:00Added an answer on May 24, 2026 at 5:26 am

    This is my url routing framework:

    function route($url, $map) {
        foreach($map as $re => $fn) {
            if(preg_match("~^$re$~", $url, $args)) {
                list($class, $method) = explode(".", $fn);
                return call_user_func_array(
                    array(new $class, $method),
                    array_slice($args, 1));
            }
        }
        error_404();
    }
    

    The $map is an array whose keys are regular expressions to match the url against and the values are strings “ClassName.method”, like

    $map = array(
        "/blog/(.+)"          => "BlogController.show",
        "/blog"               => "BlogController.blog",
        "/foobar/(\d+)/(\w+)" => "Foobar.stuff",
    );
    

    The routing function finds the first matching pattern, instantiates a class and calls a method passing regexp subgroups as arguments. So, an url “/foobar/123/hello” will be routed to Foobar->stuff(123, 'hello').

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

Sidebar

Related Questions

I wanna make the Mel-Frequency Cepstrum Algorithm but there are some things that I
i've built my first wpf application, nothing fancy, but i wanna make it look
I wanna make a query that fetches only the rows that has 'cost' value
i wanna make an attribute of an element to be unique like primary key.
i wanna make hotfile account checker inorder to start working ,i want to know
So let's say I wanna make a dictionary. We'll call it d . But
I wanna make a text editor but its different other text editors.It will get
HI Guys. I wanna know how can I make a simple search using named
I wanna do something like this: <?php $editor = new editor('reply.php?topic=100', 'simple'); echo $editor;
I'm pretty new with the Play framework. I wanna make a simple splittest framework

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.