Welcome Guest, Not a member yet? Register   Sign In
MY_Controller problems.
#1

[eluser]Unknown[/eluser]
Hello,

I was searching on forums, but don't have any idea what is wrong, I'm more than sure I did everything ok, but when try to extend MY_Controller I got error that class is not found.

Here's how it looks like.

/application/libraries/MY_Controller.php:
Code:
<?php if (!defined('BASEPATH')) exit('No direct access allowed.');

class MY_Controller extends Controller
{
    function __construct()
    {
        parent::__construct();
    }
}

/application/controllers/welcome.php:
Code:
class Welcome extends MY_Controller  {

    function __construct()
    {
          parent::__construct();    
     }

Result? Fatal error: Class 'MY_Controller' not found in welcome.php, line 3.

I'm on PHP5. Have no idea what it's not working. Any tips?

Regards
#2

[eluser]mohsin917[/eluser]
I don't know the solution but is this sure that you can not extend a controller class to a library.

/application/libraries/MY_Controller.php
#3

[eluser]Unknown[/eluser]
[quote author="mohsin917" date="1268763907"]I don't know the solution but is this sure that you can not extend a controller class to a library.

/application/libraries/MY_Controller.php[/quote]

Eee...sorry? This is the way of extending core Controller so I don't know what are you talking about. MY_Controller.php file should be placed into library folder.
#4

[eluser]mohsin917[/eluser]
Sorry I didn't now that..
#5

[eluser]n0xie[/eluser]
Try:

Code:
class MY_Controller extends Controller
{
    function MY_Controller()
    {
        parent::__construct();
    }
}
#6

[eluser]danmontgomery[/eluser]
It needs to be parent::Controller(), not parent::__construct(). __construct doesn't exist in CI core classes, since it's a PHP 5 method... Not sure if that will solve the class not being loaded, but it will be an issue nonetheless.

Code:
<?php if (!defined('BASEPATH')) exit('No direct access allowed.');

class MY_Controller extends Controller
{
    // This should work
    function __construct()
    {
        parent::Controller();
    }
}




Theme © iAndrew 2016 - Forum software by © MyBB