Codeigniter 3 dev Unable to load the requested class - php

I'm new in CI and now I'm trying to use CodeIgniter 3 to develop my site. I just only extract the framework and change only one think in config/autoload.php file:
$autoload['libraries'] = array('database','input');
when I run the site, an error occur:
Unable to load the requested class: Input
When I tried it with CI version 2.2.0 stable, every thing is OK, no errors
Could some one explain why and help me to solve it?

As of documentation input library is loaded by default.
This class (input) is initialized automatically by the system so there is no need to do it manually.
Autoloading documentation http://www.codeigniter.com/userguide3/general/autoloader.html

By default the library load from system/core folder in you CI. But the Input library is located on the core folder so you need to give relative path to the Input.php like this
$autoload['libraries'] = array('database','../core/input');

Related

Non Existent Class Error in codeigniter

I'm using codeigniter.Now I am upgrading CodeIgniter from 2.2.0 to 3.0.0
I need to use PhpExcel.But it shows an error like Non-existent class: CI_Excel
Please anyone help me.
The system/ directory is reserved for CI, you're not supposed to modify or put anything in there.
Any custom libraries you use should go into application/libraries/.
change the library name As CI_Ex.... and save it on libraries folder

codeigniter: mongodb library unable to load

I am working with code-igniter in which I want to work with MONGODB at the backend. I used the drivers from https://github.com/huglester/MongoDB-CodeIgniter-Driver ,i.e. added the config (named mongo_db.php) and library files (named Mongo_db.php) as per instructed.
I load this library in the constructor method of my model. Now the issue is that this library class doesn't load and gives me the following error:
"Unable to load the requested class: Mongo_db"
What could be the issue?
I resolved the error.
Turns out, I need to extend my loader class and customize it such that other other "users" libraries can be loaded.
Here's the link to the solution

Codeigniter DB Language extension not working

I'm trying to use this extension
But it gives me the following error when loading the library:
Unable to load the requested class: Language
Also if I write MY_Language instead, it gives me the following error:
Fatal error: Class 'CI_Language' not found in C:\wamp\www\ckphp\application\libraries\MY_Language.php on line 79
I am using WAMP and CI v. 2.2.0
Thanks!
I figured it out myself after some more researching...
Apparently the language class is not even in the library folder, but in core folder, meaning it should be placed in the core application/core folder. Also the name is not CI_Language, but CI_Lang, meaning the file name has to be MY_Lang (if MY_ is your prefix). The last thing to change in the extension is
parent::CI_Language();
to
parent::__construct();
and everything should work fine!
Usage:
$this->lang->load('set', 'language'); // To load a language
$this->lang->line('key'); // to display the text
or simply
lang('key'); // if using the language helper
Hope this will help others in the future!
I made a GIST for latest CodeIgniter 3.1.X including with migration to create the database structure
https://gist.github.com/cyberfly/885b320fdf914ae15f7316b22cc72f32

How to create log files using codeigniter

My project is going on using codeigniter.
I am new to codigniter and I want to bring log module into my project.
I want to capture all activities including errors into the log file.
Do i need to make changes in all page to store changes in log file.
where should i write function for this , whether in controller or library.
Is the log module feature exist in codeigniter?
can anyone give me the solution for this
Create library or helper and use Autoload. AFAIK codeigniter have no such default kinda library or helper, you need create your own or do research for external one.
EDIT :
My bad, try to find $config['log_threshold'] = 0; and $config['log_path'] = ''; in your config.php

HMVC and Views in folders (Codeigniter)

I am using Tank Auth library in Codeigniter with HMVC and the entire tank auth mvc files are in its own module called 'auth'. tank auth loads a view (domain.com/application/modules/auth/views/auth/login_form.php) found inside a folder (auth) using:
$this->load->view('auth/login_form', $data);
As far as I know the above code will load login_form.php inside the auth folder properly without HMVC. However with HMVC, I need the following code to get the view to load:
$this->load->view('auth/auth/login_form', $data);
Is there a setting that we should change so we dont have to refer to the view file by (module name)/(views folder name)/(view filename) ? Or is this perfectly normal and most people does it this way?
It seems troublesome that I have to add the module folder name 'auth' to every view() function call, and change all of them should I change the name of the module folder.
Assuming you're using Modular Extensions - HMVC:
If you have auth set up as a module already, you can just call:
$this->load->view('login_form', $data);
The file /views/login_form.php will be loaded from within the current module. This applies to models, language files, libraries etc. Think of the module as its own application, this is what you would normally do.
Additionally, to load a file from another module or a controller outside the module's directory, you can use $this->load->view('auth/login_form');
If the file is not found, it will check the other module paths including the default directory. This may or may not be the way other HMVC packages work, I'm not sure - but it's the way MX works.

Categories