Hello. After searching, reading the CI docs, looking at several online CI project examples and a number of github projects I can't figure this out.
What is the CI best practice to use for our own 'independent' classes and code in relation to CI's structure?
I can only find relevant info from examples in "Creating Libraries" I see
From the doc topic "Creating Libraries" I read, "However, since a library is a class, ..."
I'm used to thinking of libraries as external code that comes in some "name.lib" format or, with PHP, like these:
http://tutorialzine.com/2013/02/24-cool-...now-about/
I don't think of my own code as a library. I like bifurcating using 'Separation of Concerns.' Yet, I do not see any example of anyone 'new'ing' classes like in the code snippet below. (Note my question is general, not just about models.)
I've tried the (equivalent example ) code below in a working program; it works. Is it a bad practice to do that?
I think I understand to get 'native' access to CI functions, et cetera, I may have to make a class a library class. Is it bad practice to pass a reference to $CI into a non-CI derived class?
Thank you.
What is the CI best practice to use for our own 'independent' classes and code in relation to CI's structure?
I can only find relevant info from examples in "Creating Libraries" I see
Code:
$this->load->library('someclass');I'm used to thinking of libraries as external code that comes in some "name.lib" format or, with PHP, like these:
http://tutorialzine.com/2013/02/24-cool-...now-about/
I don't think of my own code as a library. I like bifurcating using 'Separation of Concerns.' Yet, I do not see any example of anyone 'new'ing' classes like in the code snippet below. (Note my question is general, not just about models.)
I've tried the (equivalent example ) code below in a working program; it works. Is it a bad practice to do that?
Code:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require_once( 'src/BusinessLogic.php' );
class Bigshot_model extends CI_Model
{
public function __construct()
{
parent::__construct();
$this->load->database();
}
public function getManagersSalary()
{
[...]
$bi = new BusinessLogic;
$waste = $bi->calcBloatedEgoCost( $params );
[...]
}
[...]
?>
}I think I understand to get 'native' access to CI functions, et cetera, I may have to make a class a library class. Is it bad practice to pass a reference to $CI into a non-CI derived class?
Thank you.