CodeIgniter Forums
Codeigniter 3.0 forced uppercase naming of controllers and classes - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Best Practices (https://forum.codeigniter.com/forumdisplay.php?fid=12)
+--- Thread: Codeigniter 3.0 forced uppercase naming of controllers and classes (/showthread.php?tid=65233)

Pages: 1 2


RE: Codeigniter 3.0 forced uppercase naming of controllers and classes - John_Betong - 05-19-2016

Question:

If the default ENVIRONMENT constant was temporarily set to "development" would incorrectly named files show?

PHP Code:
// define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development');
   
define)'ENVIRONMENT''development'); 

Fortunately I use Linux so don't have this problem Smile


RE: Codeigniter 3.0 forced uppercase naming of controllers and classes - stefano.corsi - 05-20-2016

(05-18-2016, 02:41 PM)kilishan Wrote: Hey stefano, you're correct that PHP can tell what case the file system reports the file as. But the tricky part is going the other direction.

In CI 2.x, IIRC, it would first look for the file as it was asked to, whether that was "FileA", "fIlEa", "filea" or whatever, If it didn't find that version of the file, it would look again for the lowercase version. That's why your scenario worked fine in previous versions. Additionally, I believe certain file types were expected to have a different capitalization than others? Don't recall for sure, but seems to tickle my memory.

In CI3 it has standardized so that all of the files are ucfirst. This keeps things consistent among the files, and keeps it working between OSs without a hitch, while allowing the framework code to be simplified, and provide a tiny performance boost at the same time. So, if you weren't used to doing it all lower case (which I will admit, I used to like better, too), then there wouldn't be any surprises when moving from one OS to another.

Hi Kilishan, thank you for the explanation.

I still cannot understand the difference between the test I made and the "other direction", I'm sure it's something I'm missing. Do you maybe have a pointer to the source code where Codeigniter looks for the file in the capitalised version?

Another question: why couldn't CI let the route.php file decide if the controller has to be lowercase or ucfirst or whatever... for example, in my route.php file I have:

$route['default_controller'] = 'website'; //lowercase

and not:

$route['default_controller'] = 'Website'; // Ucfirst

But CI 3.0 does not complain and go searching for a "Website.php" file.

Why couldn't CI simply follow the naming used by the programmer and open the corresponding file?!

S.


RE: Codeigniter 3.0 forced uppercase naming of controllers and classes - stefano.corsi - 05-20-2016

(05-18-2016, 03:20 PM)ivantcholakov Wrote: @stefano.corsi
"My post was just meant to ask if there were easy ways to revert to the old behaviour ...".

There is a way, but it is not easy. I would recommend you to have a look at my application starters that I've published at GitHub, they support both the new and the old file/class naming conventions. At some moment in the future (when I migrate all my previous works) I intend to drop this BC feature for making code cleaner and faster.

At the moment I am refactoring and modernizing a 3 years old CI-based site and I realized that without supporting the old file names it would have been difficult.

Hi @ivantcholakov

thank you for your reply.

I also feel uncomfortable in changing case of filenames in production stuff.

Could you please provide a link to your application starters?

Thank you
Stefano


RE: Codeigniter 3.0 forced uppercase naming of controllers and classes - stefano.corsi - 05-20-2016

(05-18-2016, 03:20 PM)ivantcholakov Wrote: There is a way, but it is not easy. I would recommend you to have a look at my application starters that I've published at GitHub, they support both the new and the old file/class naming conventions. At some moment in the future (when I migrate all my previous works) I intend to drop this BC feature for making code cleaner and faster.

Found it! Thanks.

https://github.com/ivantcholakov/starter-public-edition-4/


RE: Codeigniter 3.0 forced uppercase naming of controllers and classes - Narf - 05-20-2016

(05-20-2016, 03:07 AM)stefano.corsi Wrote: Another question: why couldn't CI let the route.php file decide if the controller has to be lowercase or ucfirst or whatever... for example, in my route.php file I have:

$route['default_controller'] = 'website'; //lowercase

and not:

$route['default_controller'] = 'Website'; // Ucfirst

But CI 3.0 does not complain and go searching for a "Website.php" file.

Why couldn't CI simply follow the naming used by the programmer and open the corresponding file?!

Because for every programmer that wants this, there are a 100 that would complain CI doesn't automate this.