First let me apologize if this question was answered before, I just don't seem to find the proper terms to search for it.
I'm viewing some complex PHP code with a lot of require
in it, it is kind of ineffective and time consuming to search for a function
's or variable
's definition through all the multiple level tree of files included in the current file.
so I'm wondering if a function exists that does the following:
requires
In a nutshell, a function that prints the final PHP code to be executed.
Is there such a function? if yes, what is its name?
Thank you for the help.
You cannot get the code which is going to be executed because inclusion of code can be done at run-time, based on variables whose values you don't know before running the code.
What you can do is archive all the possible code to be executed, and pack it up as a phar archive.
Using modern tools, that could mean using composer archive
.
More information available here https://getcomposer.org/doc/03-cli.md#archive
Besides, it would go against the ecosystem: in modern PHP applications, you use autoloading. Which means that even in projects with millions of lines of code and hundred of thousands of files, there is only one include/require statement.