• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Class 'Controller' not found

#1
[eluser]strike312[/eluser]
Hi Guys, just following the first tutorial video and I'm stuck actually on the very first piece of code.

I have downloaded Code Ingiter 2.0.1, and put the folder CI into my webroot folder public_html.

I have created a new php file site.php with the following code in it under the applications/controllers folder.
I have also tried using
Code:
class site extends CI_Controller.

Code:
<?php

class site extends Controller{

    function index(){

        echo "hello world!";
        
    }
}

?>

I receive the following message when accessing via localhost/ci/index.php/site

Quote:Fatal error: Class 'Controller' not found in C:\public_html\CI\application\controllers\site.php on line 3

Any ideas? I read in another post regarding the AddType and I have added the following line to the httpd.conf in the Apache folder:
Code:
AddType application/x-httpd-php .php .phtml .php3 .html
and my directory and document root is set to c:/public_html.

Any help would be appreciated.

Thanks

#2
[eluser]seb1979[/eluser]
hey,if you ever get an answer for that,i d like to know because i got the same message.I recently started learning PHP and i m following tutorials and now i m stuck.i m doing everything the guy is doing in the tutorial.

#3
[eluser]wh1tel1te[/eluser]
Guys, the tutorial videos are out-of-date and not compatible with CI 2.0. You need to prefix your controller and model extensions with "CI_", e.g.
Code:
<?php

class Home extends CI_Controller {

#4
[eluser]InsiteFX[/eluser]
For AddType you can place it in your .htaccess file.
And the above AddType is incorrect!
Correct way there are two.
Code:
// 1
AddHandler x-httpd-php5 .php .htm .html

// 2
AddHandler php5-script .php .htm .html

InsiteFX

#5
[eluser]byde[/eluser]
Also remmember, classes always start with capital, so

class site extends Controller{
rigth wway is
class Site extends Controller{

#6
[eluser]strike312[/eluser]
I have done the above suggestions, I have now added

Quote:AddHandler x-httpd-php5 .php .htm .html

to the .htaccess file in ci/applications and changed the class to a capital and using CI_Controller now
but now when i type localhost/ci/index.php/site I receive the following error:

The requested URL /ci/index.php/site was not found on this server.

Upon going to the index.php page, I now see the actual code contained within that file in my browser...

Would it just be better me downloading the older version of CodeIgniter?

#7
[eluser]wh1tel1te[/eluser]
[quote author="strike312" date="1300754744"]I have done the above suggestions, I have now added

Quote:AddHandler x-httpd-php5 .php .htm .html
[/quote]

InsiteFX should have asked for your PHP version first before suggesting that. This line will only work for PHP 5. You might have PHP 4 on your web server, which will cause your code to display as plain-text. Remove that line and see if it works again.

#8
[eluser]InsiteFX[/eluser]
If he goes into his control panel it will show which version of PHP it is running!

Also he can run phpinfo

InsiteFX

#9
[eluser]seb1979[/eluser]
that s something else, I m actually happy that everytime i followed i a tutorial in the past i would get error messages.I just got back to my php books and I should ve done that before.Reading the differences between php 4 and 5 and then work with a framework. I hear a lot of newbies like myself complaining about tutorials not being accurate and bla bla bla. when you don t understand what you're cutting and pasting means,its not a good sign.so for
newbies out here ,i want to suggest you this free book that i just found and read the part where it talks about php5 OOP.just a suggestion.the book is called: PHP5 power programming IT S FREE!!!!!!

#10
[eluser]InsiteFX[/eluser]
Also you will need to change your application/config/routes.php default controllor to site.

InsiteFX


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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