Articles → PHP CODEIGNITER → Create A Custom Library In Codeigniter

Create A Custom Library In Codeigniter


  1. Create a new file inside the "libraries" folder.
  2. The name of the file is "MyLib.php" (you can give any name).
  3. Write the following code inside the file "MyLib.php"
  4. <?php
    class MyLib
        public function MyFunc()
            echo "Calling MyFunc";

  5. Now call the class inside the controller using the following code
  6. $this->load->library('mylib');

Picture showing the output of calling the function from custom library
Click to Enlarge

Posted By  -  Karan Gupta
Posted On  -  Friday, July 24, 2020


Your Email Id  
Query/FeedbackCharacters remaining 250