Welcome Guest, Not a member yet? Register   Sign In
URI Routing: (:any) or (:segment)?
(This post was last modified: 05-06-2020, 10:54 PM by jreklund.)

Hi there,

I don't really understand the difference between (:any) and (:segment). The docs say that the placeholder (:any) "will match all characters from that point to the end of the URI. This may include multiple URI segments." and that the placeholder (:segment) "will match any character except for a forward slash (/) restricting the result to a single segment."

PHP Code:
URI = <baseurl>/part1/part2/part3

->group('part1', function($routes){

What I understand from the docs:
a. (:placeholder) == (:any) --> $1 = 'part2/part3'
b. (:placeholder) == (:segment) --> $1 = 'part2'

What happens:
c. (:placeholder) == (:any) --> $1 = 'part2', $2= 'part3', and so on...
d. (:placeholder) == (:segment) --> $1 = 'part3' and tries to find Method 'part2' in a controller called 'part1'. (This I am not sure as I could not reproduce it)

I also noticed that the behaviour of (:any) and (.+) is the same, although the docs explicitly say that "With regular expressions, you can also catch a segment containing a forward slash (‘/’), which would usually represent the delimiter between multiple segments."

How can I make a. happen? I want to return everything what is stored in another folder (like ./css/pretty.css, ./index.html, /js/somefolder/some.js).
It is easier to search the internet than posting a question. So, yes, I am asking because I did not find the answer anywhere else.

Messages In This Thread
URI Routing: (:any) or (:segment)? - by elserra - 05-06-2020, 10:05 PM

Theme © iAndrew 2016 - Forum software by © MyBB