I am building a PHP CMS from the ground up. There is one super-core file within my system which I currently have automatically importing all other packages and classes that make up the core of the system. On a typical page, only a few of these classes and methods are used.
Considering the load require_once()
puts on a server to include all of these files, and the time a user must wait for the page to load, I am wondering which path I should take:
Could someone please let me know which of the two options are the best, as well as a brief overview of its pros and cons?
Thank you for your time!!!
Earlier this year, I came upon this exact problem while developing a framework in PHP.
I considered the pros-cons and here's my evaluation:
We have two classes Rectangle
and Shape
. Rectangle
is a child class i.e. extension of Shape
. However the core script includes the classes alphabetically. Thus when Rectangle
is included, Shape
is not found and PHP will throw an error.
Rectangle
class:
class Rectangle extends Shape{
}
Shape
class:
class Shape{
}
Programming code is for human. Therefore to make things more logical and breaking down the problem, I chose option 2 to go for the framework.