• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to create custom library in CodeIgniter?

#1
CodeIgniter libraries are collection of classes located in libraries folder(i.e, application/libraries and system/libraries). Libraries are used to make the collection of related methods. You can make as many libraries in CodeIgniter as per your convenience.
Let’s start the tutorial for create custom library in CodeIgniter. Visit here:- ... OP will provide real link, please ...
Reply

#2
Considering that CI4 will be installed via composer: you can create your libraries without worrying about codeigniter methods and then upload your library to packagist. From within your codeigniter directory, composer require "companyName/yourLibrary" and then voila.

Your library file may start off like

PHP Code:
<?php
namespace MyCompanyName;

class 
math {
 public function 
multiply($a 0$b 0) {
 
  return $a $b;
 }



then in your controller file, you can do

PHP Code:
public function index() {
 
$object = new MyCompanyName\math;
 
$answer $object->multiply(45);

 
// code here to pass the variable $answer to the view

Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.