0

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

ahmad05
  • 438
  • 2
  • 6
  • 23

2 Answers2

1

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

egig
  • 4,370
  • 5
  • 29
  • 50
  • 1
    Thanks for the help. well i wont be changing core classes yet as i am still relatively new to CI :) cheers! – ahmad05 Nov 26 '13 at 06:56
0

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

Suvash sarker
  • 3,140
  • 1
  • 18
  • 21