In our project many php files contain numerous classes each
I'm writing a class (MyClass) that will be placed at the end of a long file (MyFile.php). I would like to include AnotherFile.php, for the use of many methods of MyClass. Where should I put the require directive?
I can put it before the MyClass, but that will cause it to be included every time MyFile.php is included, and I would rather spare this redundant load - it's needed only for MyClass.
I can include it inside every method of MyClass, but this is a redundant repetition.
Where can I put the require directive such that the contents of AnotherFile.php will be visible to all the methods of MyClass, but still MyFile.php will be parsed only when MyClass is used and not every time MyFile is included