Pretty url get parameters

82 views
Skip to first unread message

Kendall Arneaud

unread,
Jul 30, 2013, 5:56:31 PM7/30/13
to glu...@googlegroups.com

Your frameworks seems to be what I am looking for.

How do you create a url parameter type routing pattern?

i.e http://.../events/ <-- static
http://.../events/display/id <-- dynamic where id is get variable passed

Joe Topjian

unread,
Jul 30, 2013, 9:42:03 PM7/30/13
to glu...@googlegroups.com
Hello,

You could do it like this:

$urls = array(
  '/events' => 'events',
  '/events/display(?P<text>\d)' => 'event_id'
);

class events {
  function GET() {
    echo "Events";
  }
}

class event_id {
  function GET($matches) {
    echo "Event: $matches[1]";
  }
}

Hope that helps,
Joe


--
You received this message because you are subscribed to the Google Groups "GluePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gluephp+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Kendall Arneaud

unread,
Jul 31, 2013, 10:25:09 AM7/31/13
to glu...@googlegroups.com
Thanks I'm not good with regex but i am a proficient developer... what suggestions you have on using "method names" in the urls? i.e. " '/events/display(?P<text>\d)' => 'event_id' where events is the class display is the method and event id is the get parameter?
Reply all
Reply to author
Forward
0 new messages