The Slim Framework support forum has moved to http://discourse.slimframework.com. This Tender forum is no longer maintained or monitored.

how slim to route

james poon's Avatar

james poon

04 Mar, 2016 10:40 AM

I got an error message: Static route "/securities/groups/add" is shadowed by previously defined variable route "/securities/groups/([^/]+)" for method "GET". the routing as below:

1. /securities/groups/{id}:get
2. /securities/groups/add:get

I think it's because 2 is a subset of 1, and it works fine by reverting their position. But why it's works OK by changing the position?

  1. Support Staff 1 Posted by Andrew Smith on 05 Mar, 2016 02:59 PM

    Andrew Smith's Avatar

    Hi James,

    It works this way because of route defining order, they are matched based on the order they are set in, so based on your examples the {id} would be matched before add. This is how most routing systems work in other frameworks.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac