How to extend a base class class library? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: How to extend a base class class library? (/showthread.php?tid=5883) |
How to extend a base class class library? - El Forum - 02-07-2008 [eluser]doors[/eluser] I am writing a modules class that will be the base class for my other modules such a s payment and shipping. I am writing a test to see if I can extend a library class but it's not working. Let me know where I am going wrong. The test class is as follows. Code: class Test{ Within my controller class I load the ExtendTest class as follows: Code: class Welcome extends Controller{ I am getting an error saying: Fatal error: Class 'Test' not found in ~\system\application\libraries\ExtendTest.php How to extend a base class class library? - El Forum - 02-07-2008 [eluser]xadio[/eluser] Where is your ExtendTest.php located? Is your application located in /system/application/? There is a modules library that already exists. I haven't used it, but conceptually it seems good. Matchbox: http://code.google.com/p/matchbox/ How to extend a base class class library? - El Forum - 02-07-2008 [eluser]doors[/eluser] Can someone please help me with this issue! How to extend a base class class library? - El Forum - 02-07-2008 [eluser]doors[/eluser] Both files are located in the library folder. How to extend a base class class library? - El Forum - 02-07-2008 [eluser]xadio[/eluser] According to your controller Code: class Welcome extends Controller{ You can either load the Test Code: class Welcome extends Controller{ Or you could require Test if it is an abstract class: /ExtendTest.php Code: require_once(APPPATH.'/libraries/Test.php'); How to extend a base class class library? - El Forum - 02-07-2008 [eluser]doors[/eluser] I did the require. I was wondering if seeing that the ExtendTest extends another Class if the loader would load it and let everything flow freely. Thanks. How to extend a base class class library? - El Forum - 02-07-2008 [eluser]xadio[/eluser] [strike]I have been working with Loader.php and there is nothing in Loader. This may be because array class_parents( mixed $class [, bool $autoload ] ) is PHP5 specific. CI supports PHP4 so they aren't going to do that. The only thing close is string get_parent_class( mixed $object ) You could extend the Loader.php: /system/application/libraries/MY_Loader.php Code: class MY_Loader extends CI_Loader { Haven't tested, but should work.[/strike] How to extend a base class class library? - El Forum - 02-08-2008 [eluser]xadio[/eluser] So that didn't work. I am working on something like this and will post on my results later. |