views:

107

answers:

2

Fatal error: Class 'Controller' not found in <local_path>\system\application\controllers\welcome.php on line 3

<?php

class Welcome extends Controller {

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

    function index()
    {
        $this->load->view('welcome_message');
    }
}

/* End of file welcome.php */
/* Location: ./system/application/controllers/welcome.php */

I am beginner in php frameworks just extracted the CodeIgniter zip file and tried to run welcome.php controller in Aptana studio. ( PHP 5 )

A: 

It seems like you have Codeigniter in a different folder than '/'. If you don't change the BASEPATH or system root path in index.php or config.php, that will lead to problems.

Check lines 14-26 (?) in index.php for the "system" variable.

/*
|---------------------------------------------------------------
| SYSTEM FOLDER NAME
|---------------------------------------------------------------
|
| This variable must contain the name of your "system" folder.
| Include the path if the folder is not in the same  directory
| as this file.
|
| NO TRAILING SLASH!
|
*/
    $system_folder = "system";

Change that to reflect the path of your system folder and CI will surely find your controller class.

Pierce
A: 

the problem was that I am accessing this file directly (like what 'treeface' said), but using this route generates page not found?

127.0.0.1:8000/test_ci/index.php/welcome

then I installed WAMP and used

localhost/test_ci/index.php/welcome

and this is working!
sorry for the inconvenience!

Bero