I was wondering what is the best (and real-word) practice for doing an abstract class and subclasses in PHP when it comes to filing.
I have abstract class games
, and I was wondering if I should put the subclasses into separate files and require_once('games.class.php');
for separate files or just have each subclass in the abstract class games
file?
Thanks!
People generally tend to use one file per class -- mapping the files names to the classes names (this facilitates autoloading).
For a quite good example of this, you should take a look to the sources of Zend Framework : there are a great number of classes, with interfaces, abstract classes, multiple-levels of sub-directories and all.
And here is the relevant part of their Coding Standards.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With