Welcome Guest, Not a member yet? Register   Sign In
[SOLVED #7] Loading libraries works on desktop, but not on server.
#1

(This post was last modified: 08-19-2015, 03:04 PM by NilsFr13.)

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
Reply
#2

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

(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.
Reply
#4

So rename the file with thee first character upper case.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

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 ?
Reply
#6

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

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

Where is the solved button or checkbox ?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB