CodeIgniter Forums
File and class names - Printable Version

+- CodeIgniter Forums (
+-- Forum: CodeIgniter 4 (
+--- Forum: CodeIgniter 4 Discussion (
+--- Thread: File and class names (/thread-75118.html)

File and class names - Waithere - 12-26-2019

Hi all,

I have a question (actually more than one, but let's start with this...) about the nomenclature of files and classes in CI4.

Controllers, docs give two version with and without "Controller" termination:

PHP Code:
// Case 1
class Name extends Controller {} // Using Name.php

// Case 2
class NameController extends Controller {} // Using NameController.php 

It is the same, or just a doc error?

For the model I can see only the "NameModel" version using NameModel.php

For the entity only the "Name" version:
PHP Code:
class Name extends Entity {} // Using Name.php 

I can use all like this:
- NameController extends...
- NameModel extends...
- NameEntity extends...
without problems?

Thank you!

RE: File and class names - kilishan - 12-26-2019

Yes, you are free to name them however you would like.

RE: File and class names - InsiteFX - 12-27-2019

Just make sure that the first character is uppercase.