CodeIgniter Forums

Full Version: Accessing methods from more than one class
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi all,

Hope you can help guide me here:

I am building as app and have different controllers per object. One Controller I have is, let's say, Car, and then I have separate controllers for enginewheelschassisGPS. I know that for my car to access the wheels methods i can use:

PHP Code:
class Car extends Wheels 

But then how can my Car class also access the methods in the Engine, Chassis and GPS classes.
As I understand it, I can't extend to multiple classes. So do I just need to replicate the relevant Wheels methods in Car. It seems inefficient.
Thanks
No, those types of files should be libraries. You create them without extending the main Controller, just an empty class. And you load it in your controller car.

PHP Code:
$wheels = new \App\Libraries\Wheels(); 
@jreklund is correct you should be putting those methods in a libraries