CodeIgniter Forums
Name requirement of Controller and Model is different when extending core lib - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Name requirement of Controller and Model is different when extending core lib (/showthread.php?tid=66182)



Name requirement of Controller and Model is different when extending core lib - dangyuluo - 09-16-2016

I'm trying to extend the original CI_Controller and CI_Model to meet some of my demands. But when I do this, I found that the name requirement of extending these two core libraries is different from each other.

First, I created a file called MY_Controller.php in /application/core, and then create a class whose name does not start with the default required "MY_":
PHP Code:
class A_Controller extends CI_Controller {
public function 
__construct()
    {}


You see, though I did not meet the naming requirement (which can be seen here Creating core libraries), it actually works.

But it behaves differently when extending CI_Model. If my MY_Model.php is like this:
PHP Code:
class A_Model extends CI_Model {
public function 
__construct()
    {}


Codeigniter will throw an error telling me that:
Code:
Message: /var/www/application/core/MY_Model.php exists, but doesn't declare class MY_Model

So is the naming strategy of extending CI_Controller and CI_Molde treated differently ?


RE: Name requirement of Controller and Model is different when extending core lib - InsiteFX - 09-17-2016

Look at the CI ./system/core/Loader.php