ahmad05
ahmad05

Reputation: 458

Code Igniter Auto Load With custom name

i want to know is there way that I can pass my custom class name in autoload class

Example: in a controller i know we can do this

$this->load->library('parser','','my_parser')

but what i want to know is there way that i can pass custom name while autoloading

i.e

$autoload['libraries'] = array(('database','','my_db'));

how can i achieve this ? Thanks for the help

Upvotes: 0

Views: 850

Answers (2)

egig
egig

Reputation: 4430

it's not possible without replacing class CI_Loader, see how to replacing core class: http://ellislab.com/codeigniter%20/user-guide/general/core_classes.html , what you have to do is create same class CI_Loader with edit in this function : _ci_autoloader https://github.com/EllisLab/CodeIgniter/blob/develop/system/core/Loader.php#L1169

Upvotes: 1

Suvash sarker
Suvash sarker

Reputation: 3170

Have you tried this way:

$autoload['libraries'] = array('database', 'form_validation', 'session','custom_library');

I had a custom helper class in one of my project and load automatically by adding it to the autoload configuration file like this way

$autoload['helper'] = array('new_helper');

but never tried with library,you can try above way this may help you.

Note: The Database classes can not be extended or replaced with your own classes. All other classes are able to be replaced/extended. http://ellislab.com/codeigniter%20/user-guide/general/creating_libraries.html

Upvotes: 0

Related Questions