CodeIgniter Forums
[SOLVED #7] Loading libraries works on desktop, but not on server. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: [SOLVED #7] Loading libraries works on desktop, but not on server. (/thread-62683.html)



[SOLVED #7] Loading libraries works on desktop, but not on server. - NilsFr13 - 08-14-2015

Hi,

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 :
/var/www/html/CI/CI220_FMT1/application/libraries/fpdf/Tfpdf.php
/var/www/html/CI/CI220_FMT1/application/libraries/fpdf/Pdf_rotate.php
/var/www/html/CI/CI220_FMT1/application/libraries/fpdf/Pdf.php
/var/www/html/CI/CI220_FMT1/application/libraries/fpdf/Mpt.php

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

On server :
/var/www/html/FMT-test/CI220_FMT1/application/libraries/fpdf/Tfpdf.php
/var/www/html/FMT-test/CI220_FMT1/application/libraries/fpdf/Pdf_rotate.php
/var/www/html/FMT-test/CI220_FMT1/application/libraries/fpdf/Pdf.php
/var/www/html/FMT-test/CI220_FMT1/application/libraries/fpdf/Mpt.php

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 ?
Thanks.
Nils


RE: Loading libraries works on desktop, but not on server. - Wouter60 - 08-14-2015

You will probably find the answer here:
https://github.com/bcit-ci/CodeIgniter/issues/2202


RE: Loading libraries works on desktop, but not on server. - mwhitney - 08-14-2015

(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.


RE: Loading libraries works on desktop, but not on server. - InsiteFX - 08-14-2015

So rename the file with thee first character upper case.


RE: Loading libraries works on desktop, but not on server. - NilsFr13 - 08-17-2015

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 ?


RE: Loading libraries works on desktop, but not on server. - mwhitney - 08-17-2015

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).


RE: Loading libraries works on desktop, but not on server. - NilsFr13 - 08-17-2015

Ok, I switched to CI3.
Now loading classes works, even with subdir.


RE: Loading libraries works on desktop, but not on server. - NilsFr13 - 08-17-2015

Where is the solved button or checkbox ?