JeremyTiki Posted June 26, 2012 Share Posted June 26, 2012 Ok so I'm trying to make a small framework for personal needs, just to speed up small project time. My biggest issue right now is I want all the controllers in my application to inherit from one class the "skel_controller" but it needs to stay in a different directory. The directory structure looks like this /root /app /application controller_for_app.php /libs /skel skel_controller.php Can anyone help me with this? Quote Link to comment https://forums.phpfreaks.com/topic/264778-php-oop-inheritence-from-different-directory/ Share on other sites More sharing options...
kicken Posted June 26, 2012 Share Posted June 26, 2012 Easiest thing to do would be to either 1) add the path corresponding to your /root to the include_path setting for php, then you can just add a require_once 'libs/skel/skel_controller.php' to the top of your controllers or 2) Setup auto-loading and let that take care of including any classes when needed. Then you don't have to worry about making sure you have all the necessary require directives in your class files, php will load the class when on-demand. One of the easiest ways to handle auto-loading is to use namespaces and make each namespace level a directory. Quote Link to comment https://forums.phpfreaks.com/topic/264778-php-oop-inheritence-from-different-directory/#findComment-1356987 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.