Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best practice for filing of abstract class and subclasses?

Tags:

php

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!

like image 686
Satomi Avatar asked Mar 15 '11 20:03

Satomi


1 Answers

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.

like image 60
Pascal MARTIN Avatar answered Oct 02 '22 17:10

Pascal MARTIN