Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am in the process of upgrading CI from 1.x to 3.x
From my application/controller/home.php which has a class:

class Home extends CI_Controller {
  function __construct() {
      parent::__construct();
      $this->load->library('app_controller');
  }
...

And inside application/libraries/App_Controller.php

class App_Controller extends CI_Controller {

  function __construct() {
    parent::__construct();
    $config_app = $this->config->load('Application');
...

From application/config/Application.php I am defining variables:

$config['env']          = 'dev';
$config['https']        = '//'.$_SERVER['HTTP_HOST'].'/';
$config['js']           = '/ui/js/';

But this returns an error

An uncaught Exception was encountered
Type: Error

Message: Class 'CI_App_controller' not found

Filename: C:xampphtdocsmyprojectsystemcoreCommon.php

Any suggestions how to overcome this error and why App_Controller is not found. Thank you!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
172 views
Welcome To Ask or Share your Answers For Others

1 Answer

your libraries shouldn't extend to CI_controller.

What you want to do in that case is move your App_controller into application/core/App_controller.php.

Then go to your application/config/config.php and change your $config['subclass_prefix'] = 'MY_'; to $config['subclass_prefix'] = 'App_';

Finally your Home controller should extend to App_controller instead like so:

<?php
defined('BASEPATH') or exit('No direct script access allowed');
    class Home extends App_Controller {
      function __construct() {
          parent::__construct();
          $this->load->library('app_controller');
      }
    }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...