CodeIgniter Forums

Full Version: [SOLVED #7] Loading libraries works on desktop, but not on server.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

I am using CI220.

Making my project on Ubuntu Desktop.
Using an Ubuntu server for the web.

On my desktop, PDF libraries loads,
but the same ones does not load on my server.

Files setup.

On desktop :

Files owner:group and privileges : www-data:www-data -rw-r--r--

On server :

Files owner:group and privileges : www-data:www-data -rw-rw-r--

Loading the classes in my controller :
$this->load->library(array( 'fpdf/Tfpdf', 'fpdf/Pdf_rotate', 'fpdf/Pdf'  , 'fpdf/Mpt' ));

Files classes' names :
Tfpdf.php => class Tfpdf
Pdf_rotate.php => class Pdf_rotate extends Tfpdf
Pdf.php => class Pdf extends Pdf_rotate
Mpt.php => class Mpt extends Pdf

The error is : Unable to load the requested class: tfpdf

Why, does this works on my desktop and not on my server ?

I did not find out anything about classes in config file.

I don't know what to check ?

Can someone help me to troubleshoot this issue ?
You will probably find the answer here:
(08-14-2015, 07:02 AM)NilsFr13 Wrote: [ -> ]The error is : Unable to load the requested class: tfpdf

Is this the exact error message? The reason I ask is that the loader does something like this:
PHP Code:
// clean the input and extract the $class from the $subdir
// ...

$class ucfirst($class);

// try to load the $class from all of the library paths with the given $subdir
// ...

// If we got this far we were unable to find the requested class.

log_message('error''Unable to load the requested class: '.$class);
show_error('Unable to load the requested class: '.$class); 

So... if that's the exact error message, I'm pretty sure the loader's _ci_load_library() method has been modified, and it can't find the file because it's looking for the wrong filename.
So rename the file with thee first character upper case.
Hi all,
thank you for your answers.

Yes, I tried with or without upper case first / all letters.

The file are now, Tfdfp.php, and I tested like TFPDF.php.
It was the same.

Yes, I tried to put the classes at the root of libraries, and then no error, but a white page instead a PDF file.

I think, the best for now is switching to CI3.
What do you think about it ?
It would be best to use CI3 for new projects, since CI2 will no longer be supported after October. However, it probably won't change this specific issue for you. My previous response was based on the assumption that you were using CI3. In CI2 it's a little more complicated, but, if your class name when you call $this->load->library() (or in your autoload configuration) matches your class name in the file, and your filename matches your class name, you usually won't have any issues. Capitalization of the file name and class name must match, and you might as well make sure you use an uppercase first letter for CI3 compatibility, even if you continue to use CI2 in the short term. CI2 will try to load ucfirst($class) and strtolower($class), where CI3 will only try to load ucfirst($class).
Ok, I switched to CI3.
Now loading classes works, even with subdir.
Where is the solved button or checkbox ?