I can imagine that in large projects, some things usually become redundant in most PHP scripts. From the head: Including classes, authentication, including the configuration file, the parameter includes the path, etc.
As for my imagination, this should be done absolutely in every PHP script in the project. This would be simplified by adding a βcoreβ PHP script that handles all this.
However, from this very site I can quote
"I plan to create a PHP file" core.php "that will be included at the beginning of every EVERY SINGLE PHP file in the project. This file will handle authentication and include basic functions. Thoughts?"
I cannot stress enough, "do not do this." There is a rule among experienced PHP developers that any project with a large core.php file that is a warning sign of poor development should be avoided.
A source
Which leaves me at a loss. Is it better to redundantly write the same 20-30 lines of code on top of each file than to use DRY encoding?
Any clarifications would be appreciated!
I will quickly clarify here. The "front controller template" that I actually use when writing most websites and applications does not really match the type of project I'm talking about. Well, actually it is, and I intend to use it, but in my project there are also a lot of PHP scripts that should return content for Ajax requests. These are the PHP scripts that my question concerns.
source share