Welcome Guest, Not a member yet? Register   Sign In
BaseController and controller documentation mismatch
#11

(04-21-2020, 08:41 PM)kilishan Wrote:
(04-21-2020, 07:23 PM)dave friend Wrote: Someone should fact check me on this, but with CI4 you can name your controller using any character-case scheme you want IF you define a route for the controller. The UC first is mandatory only if you have CI figure out the controller from the URL alone.

That is correct.

I understand what you are all saying but what I still do not get is why CodeIgniter cannot figure out the controller from the URL with any kind of spelling. The part in the URL that is used for specifying the controller is case-sensitive (just because (a lot of) people use only lowercase URLs does not mean that everybody should be forced doing so).

The only argument I can imagine so far is to be compatible with older versions. But this can be solved with a flag in a conf file.

BTW: I do not want to define a route for the controller because this is just another source of error.
Reply
#12

(04-22-2020, 12:36 PM)HardyW Wrote: I understand what you are all saying but what I still do not get is why CodeIgniter cannot figure out the controller from the URL with any kind of spelling. The part in the URL that is used for specifying the controller is case-sensitive (just because (a lot of) people use only lowercase URLs does not mean that everybody should be forced doing so).

The only argument I can imagine so far is to be compatible with older versions. But this can be solved with a flag in a conf file.

BTW: I do not want to define a route for the controller because this is just another source of error.

IIRC correctly, the HTTP spec says the URL's should be treated in a case-insensitive manner.

Barring that, it's already been explained. It has to do with matching class names to right class through the autoloader. If you want to know more, please dig through the code and see if you can solve the problem. If you can make it work, then awesome - submit a PR and we'll consider it.

Personally, I find specifying the route in a routes file to be less error prone, more specific, and more flexible.
Reply
#13

(04-22-2020, 12:36 PM)HardyW Wrote: I understand what you are all saying but what I still do not get is why CodeIgniter cannot figure out the controller from the URL with any kind of [case treatment].

According to RFC1738 only the scheme part of a URL is treated in a case-ignore manner, ie. 'http', 'HTTP'. Everything else (the URI) is case sensitive, so that means a decision needs to be made on exactly how to handle the URI.

You can choose to make the user enter the URI exactly. This means that BlogShow and blogShow controllers could both exist and result in different pages being shown. But users, being who they are, will type Blogshow, receive a 404, get mad, and go somewhere else. Since we don't want to alienate possible customers we can let them be lazy and use any case they want - e.g. BLOGSHOW, bLOGShow, blogshow - and give them the same page.

(04-22-2020, 12:36 PM)HardyW Wrote: (just because (a lot of) people use only lowercase URLs does not mean that everybody should be forced doing so).

A random check of my bookmarks (and I checked many) did not reveal a single site using case sensitive URI segments. I suspect it's because they don't want to PO visitors by making the URL tricky.
Reply
#14

Hi Dave,

my most famous example is Wikipedia. Wikipedia uses case-sensitive links. And as this is one of the most used sites, I believe, I do not see any issues with using case-sensitive links. Otherwise, Wikipedia would have disappeared already a long time ago.

Example (I use German because I also wanted to check how they handle umlauts, but capitalising them seems to be OK):

https://de.wikipedia.org/wiki/Richtlinie...ichtlinie). You may try to change the spelling of the last segment (it will fail). If you change the first segment, it will partially work, namely only if you spell it "richtlinie_2000". Change it to "RIchtlinie_2000" and the page will not load.

Regards,
Hartwig
Reply




Theme © iAndrew 2016 - Forum software by © MyBB