Welcome Guest, Not a member yet? Register   Sign In
CI Way of Using Own Classes / Code
#2

What you are doing above is a good start. You have to reference the full path name to any class that you want to instantiate with new().

If you use composer then you can load your classes or APIs in this way:

use PhpOffice\PhpWord;
use PhpOffice\Common;
Lonnie Ezell's book gives an overview of using composer in codeigniter:
https://leanpub.com/practicalcodeigniter3

Codeigniter classes are singletons and so are any classes that inherit from them.

Passing in a reference to the $CI class is not a bad practice but it does couple your classes to the CI framework.
If your class has to reference any of the CI framework services then you need to reference it in some way.
Reply


Messages In This Thread
CI Way of Using Own Classes / Code - by JustBoo - 02-17-2017, 10:41 AM
RE: CI Way of Using Own Classes / Code - by Shawn - 02-18-2017, 09:58 AM



Theme © iAndrew 2016 - Forum software by © MyBB