The Slim Framework support forum has moved to 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.

  2. Josh Lockhart closed this discussion on 12 Feb, 2021 07:39 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? 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