One "compressed" class file versus multiple class files in PHP

Is there any gain for combining all classes of the project into one massive “compressed” file (spaces and comments removed) and loading of each class as needed (except for all classes, t should require / include them, not what we have __autoload for?)?

It seems to me that loading each class as needed would be much less stressful in php.

+1
php class
source share
2 answers

Typically, in the vast majority of cases, for any non-trivial number of classes, you need some kind of dependency injection. The overhead of dependency injection (using any method) will be overshadowed by the resources needed to parse a bunch of classes that will not be used in a particular query.

Much has been written about how to efficiently manage load classes as needed.

+2
source share

If you use a bytecode cache such as APC, the likelihood of your PHP “raising” (removing spaces and comments) is unlikely to be achieved. The only advantage is confusion, which is not going to buy you anyway.

And yes - loading 30 classes when you only need 1 will be a waste of resources.

+2
source share

All Articles