• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Upgrading from 1.7.2 to 2.0.2 - Moved from general discussion

#1
[eluser]mabright[/eluser]
I made all the updates but now all my pages which previously worked all error with “Fatal error: Call to undefined method CI_Controller::Controller() in ”.

So, I moved my "MY_Controller" from applications\libraries to core and now I receive just a blank screen, no errors, no page data, nothing.

I use a public controller that extends MY_Controller and the public controller is still in applications\libraries.

MY_Controller
Code:
<?php
class MY_Controller extends CI_Controller {
...
}

Public Controller
Code:
<?php
class Public_Controller extends MY_Controller {    
...
    function __construct()
    {
        parent::__construct();
    }
}

SignUp Page on website
Code:
<?php
class Signup extends Public_Controller {
...
    public function __construct()
    {
        parent::__construct();
        }
...
}

#2
[eluser]InsiteFX[/eluser]
All Controllers now extend CI_Controller
All Models now extend CI_Model

If the library you are extending is in system/core then your library goes into application/core
If the library you are extending is in system/libraries then your library goes into application/libraries

Also you need to place this code in your application/config/config.php at the very bottom!
Code:
/*
| -------------------------------------------------------------------
|  Native Autoload - by Phil Sturgeon.
| -------------------------------------------------------------------
|
| Nothing to do with config/autoload.php, this allows PHP autoload to work
| for base controllers and some third-party libraries.
|
| If using HMVC you do not need this! HMVC will autoload.
|
| Place this code at the bottom of your application/config/config.php file.
*/
function __autoload($class)
{
    if (strpos($class, 'CI_') !== 0)
    {
        @include_once(APPPATH . 'core/' . $class . EXT);
    }
}

InsiteFX

#3
[eluser]mabright[/eluser]
Thanks for the reply. I made all the suggested changed (I did not have applications\core setup before) but there is still problem with MY_Controller. I made the config.php change as suggested.

Error: "Fatal error: Call to undefined method CI_Controller::CI_Controller() in .../application/core/MY_Controller.php on line 13"

Line 13 is parent::Controller();

Code:
<?php
class MY_Controller extends CI_Controller {
...
    
    function __construct()
     {
          parent::Controller();
        }
     ...
}

#4
[eluser]TWP Marketing[/eluser]
use:
[code
...
parent::__construct();
...
[/code]

#5
[eluser]mabright[/eluser]
Thanks. That resolved the issue. Now I am receiving an error that class ion_auth cannot be loaded. Do I need to move my 3rd party classes from application\libraries?

#6
[eluser]mabright[/eluser]
Got it working. Downloaded latest Ion Auth and now all is upgraded an well. Thanks for the replies.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.