CodeIgniter Forums
Controller class not found - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Controller class not found (/showthread.php?tid=52193)

Pages: 1 2


Controller class not found - El Forum - 06-01-2012

[eluser]signtheta[/eluser]
Hi all,

i am new to PHP and CI, coming from different languages and would like some help with the following issue.

CI installed in domain-root/ci


have a Home class implemented in home.php derived from Controller but on requesting the page i get the following error message...

Fatal error: Class 'Controller' not found in /var/www/vhosts/nmcbuild.com.au/httpdocs/ci/application/controllers/home.php on line 4

i understand that php cannot resolve the Controller symbol, doesn't know where to find it.


could some one help me how to fix this please?


Controller class not found - El Forum - 06-01-2012

[eluser]LuckyFella73[/eluser]
Is your Home Class extending "Controller" or "CI_Controller"?

Should extend "CI_Controller" if you have CI >2 running.


Controller class not found - El Forum - 06-01-2012

[eluser]signtheta[/eluser]
mine is extending Controller and i am running ci 2.1.0. oh is that the issue then? i will try extending CI_Controller then.


where did you find this info mate?


thanks for the reply!


Controller class not found - El Forum - 06-01-2012

[eluser]LuckyFella73[/eluser]
In Codeigniter version < 2 your controller classes had to extend "Controller".
From CI > 2 the core-controller-class was renamed to "CI_Controller".





Controller class not found - El Forum - 06-01-2012

[eluser]signtheta[/eluser]
not it is giving me the 404 page

404 Page Not Found

The page you requested was not found.


here is my setup....


Controller class not found - El Forum - 06-01-2012

[eluser]signtheta[/eluser]
now it's giving me

404 Page Not Found

The page you requested was not found.



Code:
&lt;?php

class Home extends CI_Controller
{
var $base;
var $css;

public function Home()
{
  //parent::__construct();
  echo "HELLO World!!!";
  // echo phpinfo();
  // $base=this->config->item('base');
  // $css=this->config->item('css');
}
public function index($page)
{
  // $data['page']=$page;
  // $data['base']=$base;
  // $data['css']=$css;
  
  // this->load->view('template/header', $data);
  // this->load->view('template/menu');
  // this->load->view('under-construction');
  // this->load->view('template/footer');
}
}
?&gt;


default controller set to Home in routes.php



Controller class not found - El Forum - 06-01-2012

[eluser]LuckyFella73[/eluser]
I did copy paste your controller and it's working in my installation (2.1).

Do you make use of .htaccess to get seo urls?


Controller class not found - El Forum - 06-01-2012

[eluser]signtheta[/eluser]
i did have a .htaccess but i have removed it and tried but still the same response


Controller class not found - El Forum - 06-01-2012

[eluser]LuckyFella73[/eluser]
Try to set "home" as your default_controller in application/config/routes.php
instead of "welcome" and request the project root url. If it works you know
it has to do with your config somehow ..


Controller class not found - El Forum - 06-01-2012

[eluser]signtheta[/eluser]
can you try this url: http://nmcbuild.com.au/index.php to see the php settings