views:

258

answers:

4

Hi all,

I've been developing a website locally with CodeIgniter and have tried uploading it to my web server and get the following error (which I've never seen until the upload).

Fatal error: Class 'CI_Hooks' not found in <snip>/system/codeigniter/Common.php on line 136

I've read that CodeIgniter doesn't play nicely with PHP 5.3.x, except for their latest build (which I also downloaded and tried uploading, though simply replacing my edited files in the system directory), however I still get the same error.

Googling that message didn't help much...anybody see something similar?

+1  A: 

What version of CI that you use? I use the latest CI version 1.7.2 and in file system/codeigniter/Common.php I cannot find any call to CI_Hooks class.

Do you have custom library, or touch CI system file when developing? Have you verified that all files uploaded successfully to the server?

Donny Kurnia
That's the funny thing, I couldn't either. I will try to reupload the whole thing again...but I have not implemented anything special whatsoever, other than renaming the 'welcome' files to 'main'
espais
Maybe you upload the wrong file. It's better if you start using SCM such git, svn, mercurial to manage your source code + upload it to server, so you can make sure that the code in server is up to date and same with the one in your development machine. I prefer git and always use it whenever I can.
Donny Kurnia
turns out it was a faulty FTP upload...thanks!
espais
A: 

I had a similar problem a few months back and, unfortunately, never really identified exactly what happened. However the steps I took were the following:

Instead of uploading files and risking corruption in transfer just WGET the codeigniter zip file right to your server.

wget http://codeigniter.com/download.php

Unzip that file and then move it into your website root directory.

Now load your domain and make sure that the base CI installation is functional without ANY modifications. If that works then move your website specific files over a bit at a time and keep reloading often so you know what breaks (if anything).

In my case nothing broke so I can only assume that either SFTP was borking my files or that some other odd problem had occurred.

angryCodeMonkey
A: 

the line is in a function called load_class, and a search for 'CI_Hooks' shows that it is defined in /system/libraries/Hooks.php. Searching for 'hooks' (with the quotes) shows a line

$EXT =& load_class('Hooks');

in system/codeigniter/CodeIgniter.php

So you might just want to check if system/libraries has a Hooks.php, and that it in fact has a capital H. If not then that is your problem.

Under Windows, for various historical reasons, case of the file name ultimately does not matter, so your application would be working fine under windows but when you moved it to linux/unix, it would start giving problems.

I made this mistake once when I gave a model file name a capital first letter. This worked fine in windows, but when I deployed it in linux it immediately reported an error. Fortunately that was easier to track down.

kinjal
A: 

The loading of the 'Hooks' class happens in CodeIgniter.php on like 82. I would image that this is either an .htaccess issue of some kind, or maybe the path to your system folder is wrong.

Zack