Welcome Guest, Not a member yet? Register   Sign In
Cannot load any codeigniter libraries on Linux (Debian)
#1

[eluser]wizardoflodd[/eluser]
Hi,

I developed my codeigniter app on a windows environment and everything is working fine. I have moved it across onto a Debian server and have hit a problem that I have narrowed down to being unable to load any of the CodeIgnitier System libraries. Rather than use any of my code I can reproduce it with any of the CI example code.

e.g. I can reproduce the problem easily with the following example code (form validation class) from the CI user guide.

Code:
1 <?php
2
3 class Form extends Controller {
4    
5    function index()
6    {
7        
8       $this->load->helper(array('form', 'url'));
9        
10        $this->load->library('form_validation');
11                
12        if ($this->form_validation->run() == FALSE)
13        {
14            $this->load->view('myform');
15        }
16        else
17        {
18            $this->load->view('formsuccess');
19        }
20    }
21 }
22 ?>

When I execute this I get the error :

A PHP Error was encountered

Severity: Notice

Message: Undefined property: Form::$form_validation

Filename: controllers/form.php

Line Number: 12

Fatal error: Call to a member function run() on a non-object in /var/www/mcu/system/application/controllers/form.php on line 12

The log file has the following:

DEBUG - 2009-08-25 12:32:12 --> Config Class Initialized
DEBUG - 2009-08-25 12:32:12 --> Hooks Class Initialized
DEBUG - 2009-08-25 12:32:12 --> URI Class Initialized
DEBUG - 2009-08-25 12:32:12 --> Router Class Initialized
DEBUG - 2009-08-25 12:32:12 --> Output Class Initialized
DEBUG - 2009-08-25 12:32:12 --> Input Class Initialized
DEBUG - 2009-08-25 12:32:12 --> Global POST and COOKIE data sanitized
DEBUG - 2009-08-25 12:32:12 --> Language Class Initialized
DEBUG - 2009-08-25 12:32:12 --> Loader Class Initialized
DEBUG - 2009-08-25 12:32:12 --> Config file loaded: config/freakauth_light.php
DEBUG - 2009-08-25 12:32:12 --> Helper loaded: url_helper
DEBUG - 2009-08-25 12:32:12 --> Helper loaded: form_helper
DEBUG - 2009-08-25 12:32:12 --> Helper loaded: array_helper
DEBUG - 2009-08-25 12:32:12 --> Helper loaded: freakauth_light_helper
DEBUG - 2009-08-25 12:32:12 --> Helper loaded: html_helper
DEBUG - 2009-08-25 12:32:12 --> Database Driver Class Initialized
DEBUG - 2009-08-25 12:32:12 --> FreakAuth Class Initialized
DEBUG - 2009-08-25 12:32:12 --> Session Class Initialized (db)
DEBUG - 2009-08-25 12:32:12 --> sending session cookie
DEBUG - 2009-08-25 12:32:12 --> Model Class Initialized
DEBUG - 2009-08-25 12:32:12 --> Model Class Initialized
DEBUG - 2009-08-25 12:32:12 --> Model Class Initialized
DEBUG - 2009-08-25 12:32:12 --> Controller Class Initialized
DEBUG - 2009-08-25 12:32:12 --> Form Validation Class Initialized
ERROR - 2009-08-25 12:32:12 --> Severity: Notice --> Undefined property: Form::$form_validation /var/www/mcu/system/application/controllers/form.php 12

I'm running:

CI 1.7.1 with the freakauth plugin
Debian Linux 2.6.26-2-amd64
PHP 5.2.6-1+lenny3 with Suhosin-Patch 0.9.6.2
apache 2.2
mysql 5.0.51a-24+lenny1

I had a few problems moving it over with regards to case sensitivity and permissions which I have resolved. The /var/www directory and subdirs/files are all owner/group www-data the same as apache. My user is in the www-data group. I have a samba share to /var/www that I can write to.

I have a couple of screens that don't use any of the CI libraries and these are working fine.

I can't help thinking that it is still something to do with permissions, but I can't work out what. CI runs on linux and so I have something fundamentally wrong here !

Would value any help.

Cheers,

p.s. Sorry - I didn't mean to post this in bug reports and I don't know how to move it out now
#2

[eluser]Pascal Kriete[/eluser]
I'm not spotting where this is going wrong. After the form_validation loading call, try adding this:
Code:
echo '<pre>';
print_r($this->load->_ci_classes);
echo '</pre>';
exit;

Does that output include form_validation => form_validation?
#3

[eluser]wizardoflodd[/eluser]
Thanks Pascal,

The output is

Array
(
[freakauth_light] => freakauth_light
[db_session] => db_session
[shoppingcart] => shoppingcart
[form_validation] => form_validation
)
#4

[eluser]Pascal Kriete[/eluser]
That's strange - both that dump and the log file confirm that it the file is included, and the class is instantiated. But for some reason not tied to the super object correctly.

Could you try using this snippet, please:
Code:
// ...
$this->load->library('form_validation');

$CI =& get_instance();

if ($CI->form_validation->run() == FALSE)
{
// ....
#5

[eluser]wizardoflodd[/eluser]
Nice. That worked Smile

I've also confirmed that it works in my "real" application by doing the same.

Any ideas why that would be necessary. Something not quite right somewhere...

Thanks,
#6

[eluser]Pascal Kriete[/eluser]
Definitely something fishy going on here. get_instance() returns a reference to the controller object. So in theory it's equivalent to $this.

For the sake of this test, could you blank out your autoloading? Models, libraries, and helpers. That'll gives us a completely clean controller to work with.
#7

[eluser]wizardoflodd[/eluser]
Ok. I've removed all the array entries from autoload.php I'm back to this code

Code:
&lt;?php

class Form extends Controller {
    
    function index()
    {
        
        $this->load->helper(array('form', 'url'));  
        $this->load->library('form_validation');

if ($this->form_validation->run() == FALSE)
{

            $this->load->view('myform');
        }
        else
        {
            $this->load->view('formsuccess');
        }
    }
}
?&gt;

Here is my log output

DEBUG - 2009-08-25 16:06:34 --&gt; Config Class Initialized
DEBUG - 2009-08-25 16:06:34 --&gt; Hooks Class Initialized
DEBUG - 2009-08-25 16:06:34 --&gt; URI Class Initialized
DEBUG - 2009-08-25 16:06:34 --&gt; Router Class Initialized
DEBUG - 2009-08-25 16:06:34 --&gt; Output Class Initialized
DEBUG - 2009-08-25 16:06:34 --&gt; Input Class Initialized
DEBUG - 2009-08-25 16:06:34 --&gt; Global POST and COOKIE data sanitized
DEBUG - 2009-08-25 16:06:34 --&gt; Language Class Initialized
DEBUG - 2009-08-25 16:06:34 --&gt; Loader Class Initialized
DEBUG - 2009-08-25 16:06:34 --&gt; Controller Class Initialized
DEBUG - 2009-08-25 16:06:34 --&gt; Helper loaded: form_helper
DEBUG - 2009-08-25 16:06:34 --&gt; Helper loaded: url_helper
DEBUG - 2009-08-25 16:06:34 --&gt; Form Validation Class Initialized
ERROR - 2009-08-25 16:06:34 --&gt; Severity: Notice --&gt; Undefined property: Form::$form_validation /var/www/mcu/system/application/controllers/form.php 11

Same error to the screen as before.

I'm going to try a complete "vanilla" install of CI 1.7.1 to another folder and do the same test, to see if that shows anything different.
#8

[eluser]wizardoflodd[/eluser]
I've done a fresh install of CI 1.7.1 on the same server.

This has been pulled straight from the CI website and unzipped. All I have changed is the base_url and log_threshold in config.php

I copied form.php into system/application/controllers and ran it in the browser. I get exactly the same error and same log output

DEBUG - 2009-08-25 16:24:10 --&gt; Config Class Initialized
DEBUG - 2009-08-25 16:24:10 --&gt; Hooks Class Initialized
DEBUG - 2009-08-25 16:24:10 --&gt; URI Class Initialized
DEBUG - 2009-08-25 16:24:10 --&gt; Router Class Initialized
DEBUG - 2009-08-25 16:24:10 --&gt; Output Class Initialized
DEBUG - 2009-08-25 16:24:10 --&gt; Input Class Initialized
DEBUG - 2009-08-25 16:24:10 --&gt; Global POST and COOKIE data sanitized
DEBUG - 2009-08-25 16:24:10 --&gt; Language Class Initialized
DEBUG - 2009-08-25 16:24:10 --&gt; Loader Class Initialized
DEBUG - 2009-08-25 16:24:10 --&gt; Controller Class Initialized
DEBUG - 2009-08-25 16:24:10 --&gt; Helper loaded: form_helper
DEBUG - 2009-08-25 16:24:10 --&gt; Helper loaded: url_helper
DEBUG - 2009-08-25 16:24:10 --&gt; Form Validation Class Initialized
ERROR - 2009-08-25 16:24:10 --&gt; Severity: Notice --&gt; Undefined property: Form::$form_validation /var/www/CodeIgniter_1.7.1/system/application/controllers/form.php 11

I did find a post on the forum about someone having similar problems on the same version of php (5.2.6). They upgraded to 5.2.9 and this resolved it. There doesn't appear to be a later version of PHP on Debian though.

Only other thing to note is that I am using winscp to copy the files from windows to Debian. Even in this case I downloaded the 1.7.1.zip on windows and then used winscp to copy to Debian. Might not be relevant, but worth mentioning.
#9

[eluser]Pascal Kriete[/eluser]
Ok, slept on this and thought of one more thing.

Do you have access to your php.ini? If so, can you please make sure that zend.ze1_compatibility_mode is turned Off. That setting can cause the behavior you're seeing, but really should never be turned on.

Beyond that you might try the SVN version, but there were no changes that affected the loader that I can recall.
#10

[eluser]wizardoflodd[/eluser]
Well you must have slept very well because you have resolved my problem ! I was trying to get remote debugging working and I had set that option (amongst with some others) and forget to turn it off again

Thank you so much. I would never have come up with that solution. You have saved me hours of frustration.

Best Regards,




Theme © iAndrew 2016 - Forum software by © MyBB