Require_once in class files

by Abraham Brookes   Last Updated August 27, 2018 03:05 AM

I have a big system of classes and objects which rely on each other in order to function. Should I put all of the require_once() calls for dependencies at the top of each class file? ie:

<?php
    require_once( 'neededClass.php' );

    class MainClass{
        $this->neededClass = new neededClass();
    }
?>

Or should I make a big list of all my classes and include them at the base script?



Related Questions


What differentiates functors from poltergeists?

Updated May 03, 2018 15:05 PM

What should a constructor contain?

Updated February 25, 2018 11:05 AM

Are any side effects not concrete side effects?

Updated April 16, 2015 20:02 PM


Can I say Interface is a set of general behavior?

Updated March 01, 2017 16:05 PM