Welcome Guest, Not a member yet? Register   Sign In
Libraries Not Loading
#1

Hello, Im super new to CI and this is my 1st time using a php framework, so please bear with me...

Env.:
CI v. 3
Linux/Apache server
php v. 5.2.17
Shared hosting and I cant switch hosts at the moment. PhpStorm v9 is my IDE.

Ive uploaded CI3 and created a basic form using the form helper. I can navigate to the form without including index.php in the URL as I have created the rewrite rules and set my controller as the default in the routes file. I created a separate controller to handle form submissions. When I type $this->form_validation->set_rules(); in this 2nd controller, my IDE informs me that "Field 'form_validation' not found in class Mine." Performing $this->form_validation->run() within an if() results in a false return. I tried loading the form_validation class via the autoloader and I tried loading the class directly in my main and 2nd controller (separately) via $this->load->library() without any luck.

I confirmed that this issue also occurs with the email library.

How can I generate some log info of what the problem might be or trace the library loading functionality to figure it out that way?
Reply
#2

I think you are using the wrong version of PHP.

Here is the proper requirements.
http://www.codeigniter.com/user_guide/ge...ments.html
Reply
#3

Quote:Performing $this->form_validation->run() within an if() results in a false return.

It shows Form_validation library was loaded. If not, `$this->form_validation->run()` won't return true/false because it does not exisit.


Speaking of logging, set log_threshold in config.php:
https://github.com/bcit-ci/CodeIgniter/b...g.php#L210

and see log files in applications/logs folder.
Reply
#4

This sounds like it may simply be a configuration issue with your IDE. I'm not familiar with PHPStorm myself, but there do seem to be some solutions out there: http://stackoverflow.com/questions/12670...-framework

As @solidcodes mentioned, though, you will probably, eventually, run into some issues with the PHP version on your host. This is one case where you may need to work with CI 2 until you can change hosts (or get your host to update PHP).
Reply
#5

Please copy-paste the exact error messages, and relevant code too ... You're currently explaining what you recall about the issue and that leaves out important details.

I highly doubt the PHP version is the problem here though. You absolutely must upgrade to PHP 5.5+ either way, even if that means changing hosts, but it's not the cause for this specific problem.
My guess is that you're overriding CI_Controller::__construct() or not extending the CI_Controller class in the first place.
Reply
#6

Thanks for the responses. I was able to get the php version updated to 5.6, which Im happy about, but my issue remains. Ive sort of messed up my original description by referring to methods within my controller incorrectly, my apologies. Im only using one controller and it has two methods within it.

I was able to check the log file (logging is set to 4 for now) and it states that the library is being loaded successfully:
INFO - 2015-08-20 23:35:20 --> Form Validation Class Initialized

Ive simplified my form to just work on one field, password. Lets forget about my IDE for now. Heres my code.

The view, content is loaded along with the htm skeleton by the index method within MyClass:

PHP Code:
$password = array (
   'name'          => 'password',
   'id'            => 'password',
   'maxlength'     => '100',
   'size'          => '50'
);
$signinsubmit = array (
   'name'          => 'signinsubmit',
   'id'            => 'signinsubmit',
   'content'       => 'Sign In',
   'type'          => 'submit'
);
<
span id="testresult">result from signinsubmit displayed here</span>
echo 
form_open('myclass/signinsubmit'$signinform);
echo 
'<p>'.form_label('Password',$password['id']).form_password($password).'</p>';
echo 
'<p>'.form_button($signinsubmit).'</p>';
echo 
form_close();
echo 
validation_errors('<span class="formError">''</span>'); 


The signinsubmit method within MyClass:

PHP Code:
   $this->load->library('form_validation');
   $this->form_validation->set_rules('password''Password''required', array('required' => 'Provide Password'));
   if ($this->form_validation->run())
   {
       echo "Pass";
   }
   else
   
{
       echo "Fail";
   

The result that signinsubmit outputs: Fail
No validation errors are displayed
No errors in the log file
What am I doing wrong?
Reply
#7

I don't notice anything wrong with the code ... I suspect your rewrite rules are doing an HTTP (as opposed to interal) redirect instead, and that effectively skips the actual form post request. Can you show the .htaccess file?
Reply
#8

Well, I had tested rewrites with the full, non-default path to my system folder, which didnt work, and with the same path as my index file, which also didnt work at the time. I just retested and it does work with the same path as my index file even though I moved the system folder. Very strange, but Im glad it works and thank you for your help in pointing me in the right direction.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB