Ecosystem: PHP 7.1, self-written project, I am the main developer, C / C ++ programmer
There is a project that has a banal structure:
- index.php (+ mod_rewrite all URLs to it)
- / classes (lots of files in folders and subfolders describing functions and classes)
The project is working, everything is in order. However, there is a problem - the number of files is growing. I connect each new file through require_once(...) and they have already accumulated under a hundred. It didn't bother me
The other day there was a task to integrate into my development project of past years, which are designed as a hierarchy of classes, of which about 50+, each class in its own file, in its namespace, divided into subfolders, everything is very logical and understandable
I made a find . -name "*.php" in the forehead find . -name "*.php" find . -name "*.php" and put everything into requre_once() , as I usually did. I checked that PHP’s traces started to pour in on the fact that some class needs another class from which this one is inherited. By magical permutations of the order of connection, I achieved that it all worked
But I think this approach is not scientific, not beautiful
Question:
- How in PHP it is accepted to solve problems of dependences between classes and the order of connection of files?
- How is this connection implemented in PHP? It is desirable to native version, rather than a variant of a specific framework.
Two points of interest: connection speed / code execution speed and implementation convenience / security
I will make a reservation in advance - please, do not refer to the implementation of this mechanism in popular frameworks. I am sure that they are great and wonderful, but it is exactly Vanilla PHP 7 with standard libraries that are connected via .so.